@trieb.work/nextjs-turbo-redis-cache 1.8.0-beta.5 → 1.8.0

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.
package/src/SyncedMap.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  // SyncedMap.ts
2
- import {
3
- Client,
4
- getTimeoutRedisCommandOptions,
5
- redisErrorHandler,
6
- } from './RedisStringsHandler';
2
+ import { Client, redisErrorHandler } from './RedisStringsHandler';
7
3
  import { debugVerbose, debug } from './utils/debug';
8
4
 
9
5
  type CustomizedSync = {
@@ -16,7 +12,6 @@ type SyncedMapOptions = {
16
12
  keyPrefix: string;
17
13
  redisKey: string; // Redis Hash key
18
14
  database: number;
19
- timeoutMs: number;
20
15
  querySize: number;
21
16
  filterKeys: (key: string) => boolean;
22
17
  resyncIntervalMs?: number;
@@ -39,7 +34,6 @@ export class SyncedMap<V> {
39
34
  private syncChannel: string;
40
35
  private redisKey: string;
41
36
  private database: number;
42
- private timeoutMs: number;
43
37
  private querySize: number;
44
38
  private filterKeys: (key: string) => boolean;
45
39
  private resyncIntervalMs?: number;
@@ -54,7 +48,6 @@ export class SyncedMap<V> {
54
48
  this.redisKey = options.redisKey;
55
49
  this.syncChannel = `${options.keyPrefix}${SYNC_CHANNEL_SUFFIX}${options.redisKey}`;
56
50
  this.database = options.database;
57
- this.timeoutMs = options.timeoutMs;
58
51
  this.querySize = options.querySize;
59
52
  this.filterKeys = options.filterKeys;
60
53
  this.resyncIntervalMs = options.resyncIntervalMs;
@@ -93,9 +86,6 @@ export class SyncedMap<V> {
93
86
  'SyncedMap.initialSync(), operation: hScan ' +
94
87
  this.syncChannel +
95
88
  ' ' +
96
- this.timeoutMs +
97
- 'ms' +
98
- ' ' +
99
89
  this.keyPrefix +
100
90
  ' ' +
101
91
  this.redisKey +
@@ -104,7 +94,6 @@ export class SyncedMap<V> {
104
94
  ' ' +
105
95
  this.querySize,
106
96
  this.client.hScan(
107
- getTimeoutRedisCommandOptions(this.timeoutMs),
108
97
  this.keyPrefix + this.redisKey,
109
98
  cursor,
110
99
  hScanOptions,
@@ -135,15 +124,8 @@ export class SyncedMap<V> {
135
124
  do {
136
125
  const remoteKeysPortion = await redisErrorHandler(
137
126
  'SyncedMap.cleanupKeysNotInRedis(), operation: scan ' +
138
- this.timeoutMs +
139
- 'ms' +
140
- ' ' +
141
127
  this.keyPrefix,
142
- this.client.scan(
143
- getTimeoutRedisCommandOptions(this.timeoutMs),
144
- cursor,
145
- scanOptions,
146
- ),
128
+ this.client.scan(cursor, scanOptions),
147
129
  );
148
130
  remoteKeys = remoteKeys.concat(remoteKeysPortion.keys);
149
131
  cursor = remoteKeysPortion.cursor;
@@ -328,20 +310,15 @@ export class SyncedMap<V> {
328
310
  return;
329
311
  }
330
312
  if (!this.customizedSync?.withoutRedisHashmap) {
331
- const options = getTimeoutRedisCommandOptions(this.timeoutMs);
332
313
  operations.push(
333
314
  redisErrorHandler(
334
315
  'SyncedMap.set(), operation: hSet ' +
335
316
  this.syncChannel +
336
317
  ' ' +
337
- this.timeoutMs +
338
- 'ms' +
339
- ' ' +
340
318
  this.keyPrefix +
341
319
  ' ' +
342
320
  key,
343
321
  this.client.hSet(
344
- options,
345
322
  this.keyPrefix + this.redisKey,
346
323
  key as unknown as string,
347
324
  JSON.stringify(value),
@@ -360,9 +337,6 @@ export class SyncedMap<V> {
360
337
  'SyncedMap.set(), operation: publish ' +
361
338
  this.syncChannel +
362
339
  ' ' +
363
- this.timeoutMs +
364
- 'ms' +
365
- ' ' +
366
340
  this.keyPrefix +
367
341
  ' ' +
368
342
  key,
@@ -391,21 +365,17 @@ export class SyncedMap<V> {
391
365
  }
392
366
 
393
367
  if (!this.customizedSync?.withoutRedisHashmap) {
394
- const options = getTimeoutRedisCommandOptions(this.timeoutMs * 10);
395
368
  operations.push(
396
369
  redisErrorHandler(
397
370
  'SyncedMap.delete(), operation: hDel ' +
398
371
  this.syncChannel +
399
372
  ' ' +
400
- this.timeoutMs +
401
- 'ms' +
402
- ' ' +
403
373
  this.keyPrefix +
404
374
  ' ' +
405
375
  this.redisKey +
406
376
  ' ' +
407
377
  keysArray,
408
- this.client.hDel(options, this.keyPrefix + this.redisKey, keysArray),
378
+ this.client.hDel(this.keyPrefix + this.redisKey, keysArray),
409
379
  ),
410
380
  );
411
381
  }
@@ -420,9 +390,6 @@ export class SyncedMap<V> {
420
390
  'SyncedMap.delete(), operation: publish ' +
421
391
  this.syncChannel +
422
392
  ' ' +
423
- this.timeoutMs +
424
- 'ms' +
425
- ' ' +
426
393
  this.keyPrefix +
427
394
  ' ' +
428
395
  keysArray,