We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e6eccf9 + 599beaf commit cadcfcaCopy full SHA for cadcfca
src/store.js
@@ -36,11 +36,17 @@ export async function incrementQueueLength(store, amt) {
36
//
37
// Returns the new counter value.
38
export async function incrementAutoPeriod(store, config) {
39
- let period = Math.ceil(
+ const period = Math.ceil(
40
new Date().getTime() / (config.queue.automatic * 1000)
41
);
42
43
- return await store.incr(`${AUTO_KEY_PREFIX}:${period}`);
+ const key = `${AUTO_KEY_PREFIX}:${period}`;
44
+ const value = await store.incr(key);
45
+
46
+ // If this is the first call, set the key to expire at the end of the period.
47
+ if (value === 1) await store.expire(key, config.queue.automatic);
48
49
+ return value;
50
}
51
52
// Helper function for configuring a Redis client.
0 commit comments