qdone 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -125,7 +125,7 @@ async function statMaintenance(opt) {
125
125
  const duplicateSet = opt.cachePrefix + 'dedup-stats:duplicateSet';
126
126
  const expirationSet = opt.cachePrefix + 'dedup-stats:expirationSet';
127
127
  const client = (0, cache_js_1.getCacheClient)(opt);
128
- const now = new Date().getTime();
128
+ const now = Math.floor(Date.now() / 1000);
129
129
  // Grab a batch of expired keys
130
130
  debug({ statMaintenance: { aboutToGo: true, expirationSet } });
131
131
  const expiredStats = await client.zrange(expirationSet, '-inf', now, 'BYSCORE');
@@ -150,7 +150,7 @@ async function dedupShouldEnqueue(message, opt) {
150
150
  const client = (0, cache_js_1.getCacheClient)(opt);
151
151
  const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue;
152
152
  const cacheKey = getCacheKey(dedupId, opt);
153
- const expireAt = new Date().getTime() + opt.dedupPeriod;
153
+ const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod;
154
154
  const copies = await client.incr(cacheKey);
155
155
  debug({ action: 'shouldEnqueue', cacheKey, copies });
156
156
  if (copies === 1) {
@@ -172,7 +172,7 @@ async function dedupShouldEnqueue(message, opt) {
172
172
  */
173
173
  async function dedupShouldEnqueueMulti(messages, opt) {
174
174
  debug({ dedupShouldEnqueueMulti: { messages, opt } });
175
- const expireAt = new Date().getTime() + opt.dedupPeriod;
175
+ const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod;
176
176
  // Increment all
177
177
  const incrPipeline = (0, cache_js_1.getCacheClient)(opt).pipeline();
178
178
  for (const message of messages) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdone",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "A distributed scheduler for SQS",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/dedup.js CHANGED
@@ -112,7 +112,7 @@ export async function statMaintenance (opt) {
112
112
  const duplicateSet = opt.cachePrefix + 'dedup-stats:duplicateSet'
113
113
  const expirationSet = opt.cachePrefix + 'dedup-stats:expirationSet'
114
114
  const client = getCacheClient(opt)
115
- const now = new Date().getTime()
115
+ const now = Math.floor(Date.now() / 1000)
116
116
 
117
117
  // Grab a batch of expired keys
118
118
  debug({ statMaintenance: { aboutToGo: true, expirationSet } })
@@ -140,7 +140,7 @@ export async function dedupShouldEnqueue (message, opt) {
140
140
  const client = getCacheClient(opt)
141
141
  const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue
142
142
  const cacheKey = getCacheKey(dedupId, opt)
143
- const expireAt = new Date().getTime() + opt.dedupPeriod
143
+ const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod
144
144
  const copies = await client.incr(cacheKey)
145
145
  debug({ action: 'shouldEnqueue', cacheKey, copies })
146
146
  if (copies === 1) {
@@ -163,7 +163,7 @@ export async function dedupShouldEnqueue (message, opt) {
163
163
  */
164
164
  export async function dedupShouldEnqueueMulti (messages, opt) {
165
165
  debug({ dedupShouldEnqueueMulti: { messages, opt } })
166
- const expireAt = new Date().getTime() + opt.dedupPeriod
166
+ const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod
167
167
  // Increment all
168
168
  const incrPipeline = getCacheClient(opt).pipeline()
169
169
  for (const message of messages) {