layercache 1.2.5 → 1.2.6
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/LICENSE +190 -21
- package/README.md +254 -912
- package/dist/{chunk-7V7XAB74.js → chunk-4PPBOOXT.js} +37 -3
- package/dist/{chunk-QHWG7QS5.js → chunk-BQLL6IM5.js} +47 -1
- package/dist/{chunk-JC26W3KK.js → chunk-GJBKCFE6.js} +38 -3
- package/dist/cli.cjs +83 -3
- package/dist/cli.js +2 -2
- package/dist/{edge-P07GCO2Y.d.ts → edge-DLstcDMn.d.cts} +32 -14
- package/dist/{edge-P07GCO2Y.d.cts → edge-DLstcDMn.d.ts} +32 -14
- package/dist/edge.cjs +74 -5
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +2 -2
- package/dist/index.cjs +1070 -352
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +950 -347
- package/package.json +29 -3
- package/packages/nestjs/dist/index.cjs +722 -272
- package/packages/nestjs/dist/index.d.cts +23 -13
- package/packages/nestjs/dist/index.d.ts +23 -13
- package/packages/nestjs/dist/index.js +722 -272
|
@@ -61,6 +61,7 @@ interface CacheLayer {
|
|
|
61
61
|
clear(): Promise<void>;
|
|
62
62
|
deleteMany?(keys: string[]): Promise<void>;
|
|
63
63
|
keys?(): Promise<string[]>;
|
|
64
|
+
forEachKey?(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
64
65
|
ping?(): Promise<boolean>;
|
|
65
66
|
dispose?(): Promise<void>;
|
|
66
67
|
/**
|
|
@@ -131,10 +132,13 @@ interface CacheTagIndex {
|
|
|
131
132
|
track(key: string, tags: string[]): Promise<void>;
|
|
132
133
|
remove(key: string): Promise<void>;
|
|
133
134
|
keysForTag(tag: string): Promise<string[]>;
|
|
135
|
+
forEachKeyForTag?(tag: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
134
136
|
keysForPrefix?(prefix: string): Promise<string[]>;
|
|
137
|
+
forEachKeyForPrefix?(prefix: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
135
138
|
/** Returns the tags associated with a specific key, or an empty array. */
|
|
136
139
|
tagsForKey?(key: string): Promise<string[]>;
|
|
137
140
|
matchPattern(pattern: string): Promise<string[]>;
|
|
141
|
+
forEachKeyMatchingPattern?(pattern: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
138
142
|
clear(): Promise<void>;
|
|
139
143
|
}
|
|
140
144
|
interface CacheLayerSetManyEntry {
|
|
@@ -194,6 +198,9 @@ interface CacheStackOptions {
|
|
|
194
198
|
singleFlightPollMs?: number;
|
|
195
199
|
singleFlightRenewIntervalMs?: number;
|
|
196
200
|
snapshotBaseDir?: string | false;
|
|
201
|
+
snapshotMaxBytes?: number | false;
|
|
202
|
+
snapshotMaxEntries?: number | false;
|
|
203
|
+
invalidationMaxKeys?: number | false;
|
|
197
204
|
/**
|
|
198
205
|
* Maximum number of entries in `accessProfiles` and `circuitBreakers` maps
|
|
199
206
|
* before the oldest entries are pruned. Prevents unbounded memory growth.
|
|
@@ -386,6 +393,10 @@ declare class CacheNamespace {
|
|
|
386
393
|
*/
|
|
387
394
|
namespace(childPrefix: string): CacheNamespace;
|
|
388
395
|
qualify(key: string): string;
|
|
396
|
+
private qualifyTag;
|
|
397
|
+
private qualifyGetOptions;
|
|
398
|
+
private qualifyWrapOptions;
|
|
399
|
+
private qualifyWriteOptions;
|
|
389
400
|
private trackMetrics;
|
|
390
401
|
private getMetricsMutex;
|
|
391
402
|
}
|
|
@@ -415,6 +426,7 @@ declare class CacheStack extends EventEmitter {
|
|
|
415
426
|
private readonly snapshotSerializer;
|
|
416
427
|
private readonly backgroundRefreshes;
|
|
417
428
|
private readonly layerDegradedUntil;
|
|
429
|
+
private readonly keyEpochs;
|
|
418
430
|
private readonly ttlResolver;
|
|
419
431
|
private readonly circuitBreakerManager;
|
|
420
432
|
private currentGeneration?;
|
|
@@ -422,6 +434,7 @@ declare class CacheStack extends EventEmitter {
|
|
|
422
434
|
private writeBehindTimer?;
|
|
423
435
|
private writeBehindFlushPromise?;
|
|
424
436
|
private generationCleanupPromise?;
|
|
437
|
+
private clearEpoch;
|
|
425
438
|
private isDisconnecting;
|
|
426
439
|
private disconnectPromise?;
|
|
427
440
|
constructor(layers: CacheLayer[], options?: CacheStackOptions);
|
|
@@ -539,6 +552,10 @@ declare class CacheStack extends EventEmitter {
|
|
|
539
552
|
private cleanupGeneration;
|
|
540
553
|
private initializeWriteBehind;
|
|
541
554
|
private shouldWriteBehind;
|
|
555
|
+
private beginClearEpoch;
|
|
556
|
+
private currentKeyEpoch;
|
|
557
|
+
private bumpKeyEpochs;
|
|
558
|
+
private isWriteOutdated;
|
|
542
559
|
private enqueueWriteBehind;
|
|
543
560
|
private flushWriteBehindQueue;
|
|
544
561
|
private buildLayerSetEntry;
|
|
@@ -550,18 +567,8 @@ declare class CacheStack extends EventEmitter {
|
|
|
550
567
|
private deleteKeysFromLayers;
|
|
551
568
|
private validateConfiguration;
|
|
552
569
|
private validateWriteOptions;
|
|
553
|
-
private validateLayerNumberOption;
|
|
554
|
-
private validatePositiveNumber;
|
|
555
|
-
private validateRateLimitOptions;
|
|
556
|
-
private validateNonNegativeNumber;
|
|
557
|
-
private validateCacheKey;
|
|
558
|
-
private validatePattern;
|
|
559
|
-
private validateTtlPolicy;
|
|
560
570
|
private assertActive;
|
|
561
571
|
private awaitStartup;
|
|
562
|
-
private serializeOptions;
|
|
563
|
-
private validateAdaptiveTtlOptions;
|
|
564
|
-
private validateCircuitBreakerOptions;
|
|
565
572
|
private applyFreshReadPolicies;
|
|
566
573
|
private shouldSkipLayer;
|
|
567
574
|
private handleLayerFailure;
|
|
@@ -570,11 +577,14 @@ declare class CacheStack extends EventEmitter {
|
|
|
570
577
|
private recordCircuitFailure;
|
|
571
578
|
private isNegativeStoredValue;
|
|
572
579
|
private emitError;
|
|
573
|
-
private serializeKeyPart;
|
|
574
580
|
private isCacheSnapshotEntries;
|
|
575
581
|
private sanitizeSnapshotValue;
|
|
576
|
-
private
|
|
577
|
-
private
|
|
582
|
+
private snapshotMaxBytes;
|
|
583
|
+
private snapshotMaxEntries;
|
|
584
|
+
private invalidationMaxKeys;
|
|
585
|
+
private collectKeysForTag;
|
|
586
|
+
private assertWithinInvalidationKeyLimit;
|
|
587
|
+
private visitExportEntries;
|
|
578
588
|
}
|
|
579
589
|
|
|
580
590
|
interface CacheableOptions<TArgs extends unknown[]> extends CacheWrapOptions<TArgs> {
|
|
@@ -61,6 +61,7 @@ interface CacheLayer {
|
|
|
61
61
|
clear(): Promise<void>;
|
|
62
62
|
deleteMany?(keys: string[]): Promise<void>;
|
|
63
63
|
keys?(): Promise<string[]>;
|
|
64
|
+
forEachKey?(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
64
65
|
ping?(): Promise<boolean>;
|
|
65
66
|
dispose?(): Promise<void>;
|
|
66
67
|
/**
|
|
@@ -131,10 +132,13 @@ interface CacheTagIndex {
|
|
|
131
132
|
track(key: string, tags: string[]): Promise<void>;
|
|
132
133
|
remove(key: string): Promise<void>;
|
|
133
134
|
keysForTag(tag: string): Promise<string[]>;
|
|
135
|
+
forEachKeyForTag?(tag: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
134
136
|
keysForPrefix?(prefix: string): Promise<string[]>;
|
|
137
|
+
forEachKeyForPrefix?(prefix: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
135
138
|
/** Returns the tags associated with a specific key, or an empty array. */
|
|
136
139
|
tagsForKey?(key: string): Promise<string[]>;
|
|
137
140
|
matchPattern(pattern: string): Promise<string[]>;
|
|
141
|
+
forEachKeyMatchingPattern?(pattern: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
138
142
|
clear(): Promise<void>;
|
|
139
143
|
}
|
|
140
144
|
interface CacheLayerSetManyEntry {
|
|
@@ -194,6 +198,9 @@ interface CacheStackOptions {
|
|
|
194
198
|
singleFlightPollMs?: number;
|
|
195
199
|
singleFlightRenewIntervalMs?: number;
|
|
196
200
|
snapshotBaseDir?: string | false;
|
|
201
|
+
snapshotMaxBytes?: number | false;
|
|
202
|
+
snapshotMaxEntries?: number | false;
|
|
203
|
+
invalidationMaxKeys?: number | false;
|
|
197
204
|
/**
|
|
198
205
|
* Maximum number of entries in `accessProfiles` and `circuitBreakers` maps
|
|
199
206
|
* before the oldest entries are pruned. Prevents unbounded memory growth.
|
|
@@ -386,6 +393,10 @@ declare class CacheNamespace {
|
|
|
386
393
|
*/
|
|
387
394
|
namespace(childPrefix: string): CacheNamespace;
|
|
388
395
|
qualify(key: string): string;
|
|
396
|
+
private qualifyTag;
|
|
397
|
+
private qualifyGetOptions;
|
|
398
|
+
private qualifyWrapOptions;
|
|
399
|
+
private qualifyWriteOptions;
|
|
389
400
|
private trackMetrics;
|
|
390
401
|
private getMetricsMutex;
|
|
391
402
|
}
|
|
@@ -415,6 +426,7 @@ declare class CacheStack extends EventEmitter {
|
|
|
415
426
|
private readonly snapshotSerializer;
|
|
416
427
|
private readonly backgroundRefreshes;
|
|
417
428
|
private readonly layerDegradedUntil;
|
|
429
|
+
private readonly keyEpochs;
|
|
418
430
|
private readonly ttlResolver;
|
|
419
431
|
private readonly circuitBreakerManager;
|
|
420
432
|
private currentGeneration?;
|
|
@@ -422,6 +434,7 @@ declare class CacheStack extends EventEmitter {
|
|
|
422
434
|
private writeBehindTimer?;
|
|
423
435
|
private writeBehindFlushPromise?;
|
|
424
436
|
private generationCleanupPromise?;
|
|
437
|
+
private clearEpoch;
|
|
425
438
|
private isDisconnecting;
|
|
426
439
|
private disconnectPromise?;
|
|
427
440
|
constructor(layers: CacheLayer[], options?: CacheStackOptions);
|
|
@@ -539,6 +552,10 @@ declare class CacheStack extends EventEmitter {
|
|
|
539
552
|
private cleanupGeneration;
|
|
540
553
|
private initializeWriteBehind;
|
|
541
554
|
private shouldWriteBehind;
|
|
555
|
+
private beginClearEpoch;
|
|
556
|
+
private currentKeyEpoch;
|
|
557
|
+
private bumpKeyEpochs;
|
|
558
|
+
private isWriteOutdated;
|
|
542
559
|
private enqueueWriteBehind;
|
|
543
560
|
private flushWriteBehindQueue;
|
|
544
561
|
private buildLayerSetEntry;
|
|
@@ -550,18 +567,8 @@ declare class CacheStack extends EventEmitter {
|
|
|
550
567
|
private deleteKeysFromLayers;
|
|
551
568
|
private validateConfiguration;
|
|
552
569
|
private validateWriteOptions;
|
|
553
|
-
private validateLayerNumberOption;
|
|
554
|
-
private validatePositiveNumber;
|
|
555
|
-
private validateRateLimitOptions;
|
|
556
|
-
private validateNonNegativeNumber;
|
|
557
|
-
private validateCacheKey;
|
|
558
|
-
private validatePattern;
|
|
559
|
-
private validateTtlPolicy;
|
|
560
570
|
private assertActive;
|
|
561
571
|
private awaitStartup;
|
|
562
|
-
private serializeOptions;
|
|
563
|
-
private validateAdaptiveTtlOptions;
|
|
564
|
-
private validateCircuitBreakerOptions;
|
|
565
572
|
private applyFreshReadPolicies;
|
|
566
573
|
private shouldSkipLayer;
|
|
567
574
|
private handleLayerFailure;
|
|
@@ -570,11 +577,14 @@ declare class CacheStack extends EventEmitter {
|
|
|
570
577
|
private recordCircuitFailure;
|
|
571
578
|
private isNegativeStoredValue;
|
|
572
579
|
private emitError;
|
|
573
|
-
private serializeKeyPart;
|
|
574
580
|
private isCacheSnapshotEntries;
|
|
575
581
|
private sanitizeSnapshotValue;
|
|
576
|
-
private
|
|
577
|
-
private
|
|
582
|
+
private snapshotMaxBytes;
|
|
583
|
+
private snapshotMaxEntries;
|
|
584
|
+
private invalidationMaxKeys;
|
|
585
|
+
private collectKeysForTag;
|
|
586
|
+
private assertWithinInvalidationKeyLimit;
|
|
587
|
+
private visitExportEntries;
|
|
578
588
|
}
|
|
579
589
|
|
|
580
590
|
interface CacheableOptions<TArgs extends unknown[]> extends CacheWrapOptions<TArgs> {
|