diff --git a/src/classes/queue.ts b/src/classes/queue.ts index 76b68a1303..557319c30f 100644 --- a/src/classes/queue.ts +++ b/src/classes/queue.ts @@ -120,8 +120,8 @@ export class Queue< this.waitUntilReady() .then(client => { - if (!this.closing) { - client.hmset(this.keys.meta, this.metaValues); + if (!this.closing && !opts?.skipMetasUpdate) { + return client.hmset(this.keys.meta, this.metaValues); } }) .catch(err => { diff --git a/src/interfaces/queue-options.ts b/src/interfaces/queue-options.ts index c8f00bd78c..0f771403b9 100644 --- a/src/interfaces/queue-options.ts +++ b/src/interfaces/queue-options.ts @@ -54,6 +54,19 @@ export interface QueueOptions extends QueueBaseOptions { }; }; + /** + * Skip Meta update. + * + * If true, the queue will not update the metadata of the queue. + * Useful for read-only systems that do should not update the metadata. + * + * @defaultValue false + */ + skipMetasUpdate?: boolean; + + /** + * Advanced options for the repeatable jobs. + */ settings?: AdvancedRepeatOptions; } diff --git a/tests/test_queue.ts b/tests/test_queue.ts index 435ca89ced..23ddf7ffba 100644 --- a/tests/test_queue.ts +++ b/tests/test_queue.ts @@ -44,6 +44,15 @@ describe('queues', function () { return queue.close(); }); + it('should return default library version when using skipMetasUpdate', async () => { + const exQueueName = `test-${v4()}`; + const queue = new Queue(exQueueName, { connection, skipMetasUpdate: true }); + const version = await queue.getVersion(); + expect(version).to.be.equal(null); + await queue.close(); + await removeAllQueueData(new IORedis(redisHost), exQueueName); + }); + describe('.add', () => { describe('when jobId is provided as integer', () => { it('throws error', async function () {