layercache 1.2.5 → 1.2.7
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-BMmPVqaD.d.cts} +28 -21
- package/dist/{edge-P07GCO2Y.d.cts → edge-BMmPVqaD.d.ts} +28 -21
- 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 +1671 -837
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +1327 -608
- package/package.json +29 -3
- package/packages/nestjs/dist/index.cjs +1296 -732
- package/packages/nestjs/dist/index.d.cts +19 -20
- package/packages/nestjs/dist/index.d.ts +19 -20
- package/packages/nestjs/dist/index.js +1296 -732
|
@@ -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,13 +426,10 @@ declare class CacheStack extends EventEmitter {
|
|
|
415
426
|
private readonly snapshotSerializer;
|
|
416
427
|
private readonly backgroundRefreshes;
|
|
417
428
|
private readonly layerDegradedUntil;
|
|
429
|
+
private readonly maintenance;
|
|
418
430
|
private readonly ttlResolver;
|
|
419
431
|
private readonly circuitBreakerManager;
|
|
420
432
|
private currentGeneration?;
|
|
421
|
-
private readonly writeBehindQueue;
|
|
422
|
-
private writeBehindTimer?;
|
|
423
|
-
private writeBehindFlushPromise?;
|
|
424
|
-
private generationCleanupPromise?;
|
|
425
433
|
private isDisconnecting;
|
|
426
434
|
private disconnectPromise?;
|
|
427
435
|
constructor(layers: CacheLayer[], options?: CacheStackOptions);
|
|
@@ -533,35 +541,23 @@ declare class CacheStack extends EventEmitter {
|
|
|
533
541
|
private sleep;
|
|
534
542
|
private withTimeout;
|
|
535
543
|
private shouldBroadcastL1Invalidation;
|
|
536
|
-
private shouldCleanupGenerations;
|
|
537
|
-
private generationCleanupBatchSize;
|
|
538
544
|
private scheduleGenerationCleanup;
|
|
539
545
|
private cleanupGeneration;
|
|
540
546
|
private initializeWriteBehind;
|
|
541
547
|
private shouldWriteBehind;
|
|
542
548
|
private enqueueWriteBehind;
|
|
543
549
|
private flushWriteBehindQueue;
|
|
550
|
+
private runWriteBehindBatch;
|
|
544
551
|
private buildLayerSetEntry;
|
|
545
552
|
private intersectKeys;
|
|
546
553
|
private qualifyKey;
|
|
547
554
|
private qualifyPattern;
|
|
548
555
|
private stripQualifiedKey;
|
|
549
|
-
private generationPrefix;
|
|
550
556
|
private deleteKeysFromLayers;
|
|
551
557
|
private validateConfiguration;
|
|
552
558
|
private validateWriteOptions;
|
|
553
|
-
private validateLayerNumberOption;
|
|
554
|
-
private validatePositiveNumber;
|
|
555
|
-
private validateRateLimitOptions;
|
|
556
|
-
private validateNonNegativeNumber;
|
|
557
|
-
private validateCacheKey;
|
|
558
|
-
private validatePattern;
|
|
559
|
-
private validateTtlPolicy;
|
|
560
559
|
private assertActive;
|
|
561
560
|
private awaitStartup;
|
|
562
|
-
private serializeOptions;
|
|
563
|
-
private validateAdaptiveTtlOptions;
|
|
564
|
-
private validateCircuitBreakerOptions;
|
|
565
561
|
private applyFreshReadPolicies;
|
|
566
562
|
private shouldSkipLayer;
|
|
567
563
|
private handleLayerFailure;
|
|
@@ -570,11 +566,14 @@ declare class CacheStack extends EventEmitter {
|
|
|
570
566
|
private recordCircuitFailure;
|
|
571
567
|
private isNegativeStoredValue;
|
|
572
568
|
private emitError;
|
|
573
|
-
private serializeKeyPart;
|
|
574
569
|
private isCacheSnapshotEntries;
|
|
575
570
|
private sanitizeSnapshotValue;
|
|
576
|
-
private
|
|
577
|
-
private
|
|
571
|
+
private snapshotMaxBytes;
|
|
572
|
+
private snapshotMaxEntries;
|
|
573
|
+
private invalidationMaxKeys;
|
|
574
|
+
private collectKeysForTag;
|
|
575
|
+
private assertWithinInvalidationKeyLimit;
|
|
576
|
+
private visitExportEntries;
|
|
578
577
|
}
|
|
579
578
|
|
|
580
579
|
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,13 +426,10 @@ declare class CacheStack extends EventEmitter {
|
|
|
415
426
|
private readonly snapshotSerializer;
|
|
416
427
|
private readonly backgroundRefreshes;
|
|
417
428
|
private readonly layerDegradedUntil;
|
|
429
|
+
private readonly maintenance;
|
|
418
430
|
private readonly ttlResolver;
|
|
419
431
|
private readonly circuitBreakerManager;
|
|
420
432
|
private currentGeneration?;
|
|
421
|
-
private readonly writeBehindQueue;
|
|
422
|
-
private writeBehindTimer?;
|
|
423
|
-
private writeBehindFlushPromise?;
|
|
424
|
-
private generationCleanupPromise?;
|
|
425
433
|
private isDisconnecting;
|
|
426
434
|
private disconnectPromise?;
|
|
427
435
|
constructor(layers: CacheLayer[], options?: CacheStackOptions);
|
|
@@ -533,35 +541,23 @@ declare class CacheStack extends EventEmitter {
|
|
|
533
541
|
private sleep;
|
|
534
542
|
private withTimeout;
|
|
535
543
|
private shouldBroadcastL1Invalidation;
|
|
536
|
-
private shouldCleanupGenerations;
|
|
537
|
-
private generationCleanupBatchSize;
|
|
538
544
|
private scheduleGenerationCleanup;
|
|
539
545
|
private cleanupGeneration;
|
|
540
546
|
private initializeWriteBehind;
|
|
541
547
|
private shouldWriteBehind;
|
|
542
548
|
private enqueueWriteBehind;
|
|
543
549
|
private flushWriteBehindQueue;
|
|
550
|
+
private runWriteBehindBatch;
|
|
544
551
|
private buildLayerSetEntry;
|
|
545
552
|
private intersectKeys;
|
|
546
553
|
private qualifyKey;
|
|
547
554
|
private qualifyPattern;
|
|
548
555
|
private stripQualifiedKey;
|
|
549
|
-
private generationPrefix;
|
|
550
556
|
private deleteKeysFromLayers;
|
|
551
557
|
private validateConfiguration;
|
|
552
558
|
private validateWriteOptions;
|
|
553
|
-
private validateLayerNumberOption;
|
|
554
|
-
private validatePositiveNumber;
|
|
555
|
-
private validateRateLimitOptions;
|
|
556
|
-
private validateNonNegativeNumber;
|
|
557
|
-
private validateCacheKey;
|
|
558
|
-
private validatePattern;
|
|
559
|
-
private validateTtlPolicy;
|
|
560
559
|
private assertActive;
|
|
561
560
|
private awaitStartup;
|
|
562
|
-
private serializeOptions;
|
|
563
|
-
private validateAdaptiveTtlOptions;
|
|
564
|
-
private validateCircuitBreakerOptions;
|
|
565
561
|
private applyFreshReadPolicies;
|
|
566
562
|
private shouldSkipLayer;
|
|
567
563
|
private handleLayerFailure;
|
|
@@ -570,11 +566,14 @@ declare class CacheStack extends EventEmitter {
|
|
|
570
566
|
private recordCircuitFailure;
|
|
571
567
|
private isNegativeStoredValue;
|
|
572
568
|
private emitError;
|
|
573
|
-
private serializeKeyPart;
|
|
574
569
|
private isCacheSnapshotEntries;
|
|
575
570
|
private sanitizeSnapshotValue;
|
|
576
|
-
private
|
|
577
|
-
private
|
|
571
|
+
private snapshotMaxBytes;
|
|
572
|
+
private snapshotMaxEntries;
|
|
573
|
+
private invalidationMaxKeys;
|
|
574
|
+
private collectKeysForTag;
|
|
575
|
+
private assertWithinInvalidationKeyLimit;
|
|
576
|
+
private visitExportEntries;
|
|
578
577
|
}
|
|
579
578
|
|
|
580
579
|
interface CacheableOptions<TArgs extends unknown[]> extends CacheWrapOptions<TArgs> {
|