layercache 1.2.1 → 1.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.
- package/README.md +66 -11
- package/dist/{chunk-ZMDB5KOK.js → chunk-7V7XAB74.js} +24 -1
- package/dist/{chunk-46UH7LNM.js → chunk-KOYGHLVP.js} +142 -18
- package/dist/{chunk-GF47Y3XR.js → chunk-QHWG7QS5.js} +56 -25
- package/dist/cli.cjs +92 -27
- package/dist/cli.js +15 -4
- package/dist/{edge-C1sBhTfv.d.ts → edge-B_rUqDy6.d.cts} +39 -1
- package/dist/{edge-C1sBhTfv.d.cts → edge-B_rUqDy6.d.ts} +39 -1
- package/dist/edge.cjs +165 -17
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +2 -2
- package/dist/index.cjs +798 -127
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +582 -90
- package/package.json +5 -5
- package/packages/nestjs/dist/index.cjs +582 -61
- package/packages/nestjs/dist/index.d.cts +30 -0
- package/packages/nestjs/dist/index.d.ts +30 -0
- package/packages/nestjs/dist/index.js +582 -61
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvalidationBus, C as CacheLogger, a as InvalidationMessage, b as CacheTagIndex, c as CacheStack, d as CacheWrapOptions, e as CacheGetOptions, f as CacheLayer, g as CacheSerializer, h as CacheLayerSetManyEntry, i as CacheSingleFlightCoordinator, j as CacheSingleFlightExecutionOptions } from './edge-
|
|
2
|
-
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheDegradationOptions, n as CacheHealthCheckResult, o as CacheHitRateSnapshot, p as CacheInspectResult, q as CacheLayerLatency, r as CacheMGetEntry, s as CacheMSetEntry, t as CacheMetricsSnapshot, u as CacheMissError, v as CacheNamespace, w as CacheRateLimitOptions, x as CacheSnapshotEntry, y as CacheStackEvents, z as CacheStackOptions, A as CacheStatsSnapshot, B as CacheTtlPolicy, D as CacheTtlPolicyContext, E as CacheWarmEntry, F as CacheWarmOptions, G as CacheWarmProgress, H as CacheWriteBehindOptions, J as CacheWriteOptions, K as EvictionPolicy, L as LayerTtlMap, M as MemoryLayer, N as MemoryLayerOptions, O as MemoryLayerSnapshotEntry, P as PatternMatcher, T as TagIndex, Q as createHonoCacheMiddleware } from './edge-
|
|
1
|
+
import { I as InvalidationBus, C as CacheLogger, a as InvalidationMessage, b as CacheTagIndex, c as CacheStack, d as CacheWrapOptions, e as CacheGetOptions, f as CacheLayer, g as CacheSerializer, h as CacheLayerSetManyEntry, i as CacheSingleFlightCoordinator, j as CacheSingleFlightExecutionOptions } from './edge-B_rUqDy6.cjs';
|
|
2
|
+
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheDegradationOptions, n as CacheHealthCheckResult, o as CacheHitRateSnapshot, p as CacheInspectResult, q as CacheLayerLatency, r as CacheMGetEntry, s as CacheMSetEntry, t as CacheMetricsSnapshot, u as CacheMissError, v as CacheNamespace, w as CacheRateLimitOptions, x as CacheSnapshotEntry, y as CacheStackEvents, z as CacheStackOptions, A as CacheStatsSnapshot, B as CacheTtlPolicy, D as CacheTtlPolicyContext, E as CacheWarmEntry, F as CacheWarmOptions, G as CacheWarmProgress, H as CacheWriteBehindOptions, J as CacheWriteOptions, K as EvictionPolicy, L as LayerTtlMap, M as MemoryLayer, N as MemoryLayerOptions, O as MemoryLayerSnapshotEntry, P as PatternMatcher, T as TagIndex, Q as createHonoCacheMiddleware } from './edge-B_rUqDy6.cjs';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
@@ -35,11 +35,13 @@ interface RedisTagIndexOptions {
|
|
|
35
35
|
client: Redis;
|
|
36
36
|
prefix?: string;
|
|
37
37
|
scanCount?: number;
|
|
38
|
+
knownKeysShards?: number;
|
|
38
39
|
}
|
|
39
40
|
declare class RedisTagIndex implements CacheTagIndex {
|
|
40
41
|
private readonly client;
|
|
41
42
|
private readonly prefix;
|
|
42
43
|
private readonly scanCount;
|
|
44
|
+
private readonly knownKeysShards;
|
|
43
45
|
constructor(options: RedisTagIndexOptions);
|
|
44
46
|
touch(key: string): Promise<void>;
|
|
45
47
|
track(key: string, tags: string[]): Promise<void>;
|
|
@@ -50,7 +52,8 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
50
52
|
matchPattern(pattern: string): Promise<string[]>;
|
|
51
53
|
clear(): Promise<void>;
|
|
52
54
|
private scanIndexKeys;
|
|
53
|
-
private
|
|
55
|
+
private knownKeysKeyFor;
|
|
56
|
+
private knownKeysKeys;
|
|
54
57
|
private keyTagsKey;
|
|
55
58
|
private tagKeysKey;
|
|
56
59
|
}
|
|
@@ -173,6 +176,11 @@ interface RedisLayerOptions {
|
|
|
173
176
|
scanCount?: number;
|
|
174
177
|
compression?: CompressionAlgorithm;
|
|
175
178
|
compressionThreshold?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Maximum number of bytes allowed after decompression.
|
|
181
|
+
* Prevents decompression bomb attacks. Defaults to 64 MiB.
|
|
182
|
+
*/
|
|
183
|
+
decompressionMaxBytes?: number;
|
|
176
184
|
disconnectOnDispose?: boolean;
|
|
177
185
|
}
|
|
178
186
|
declare class RedisLayer implements CacheLayer {
|
|
@@ -186,6 +194,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
186
194
|
private readonly scanCount;
|
|
187
195
|
private readonly compression?;
|
|
188
196
|
private readonly compressionThreshold;
|
|
197
|
+
private readonly decompressionMaxBytes;
|
|
189
198
|
private readonly disconnectOnDispose;
|
|
190
199
|
constructor(options: RedisLayerOptions);
|
|
191
200
|
get<T>(key: string): Promise<T | null>;
|
|
@@ -219,6 +228,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
219
228
|
private encodePayload;
|
|
220
229
|
/**
|
|
221
230
|
* Decompresses the payload asynchronously if a compression header is present.
|
|
231
|
+
* Enforces a maximum decompressed size to prevent decompression bomb attacks.
|
|
222
232
|
*/
|
|
223
233
|
private decodePayload;
|
|
224
234
|
}
|
|
@@ -274,6 +284,9 @@ declare class DiskLayer implements CacheLayer {
|
|
|
274
284
|
ping(): Promise<boolean>;
|
|
275
285
|
dispose(): Promise<void>;
|
|
276
286
|
private keyToPath;
|
|
287
|
+
private resolveDirectory;
|
|
288
|
+
private normalizeMaxFiles;
|
|
289
|
+
private deserializeEntry;
|
|
277
290
|
private safeDelete;
|
|
278
291
|
private enqueueWrite;
|
|
279
292
|
/**
|
|
@@ -341,6 +354,7 @@ declare class MemcachedLayer implements CacheLayer {
|
|
|
341
354
|
deleteMany(keys: string[]): Promise<void>;
|
|
342
355
|
clear(): Promise<void>;
|
|
343
356
|
private withPrefix;
|
|
357
|
+
private validateKey;
|
|
344
358
|
}
|
|
345
359
|
|
|
346
360
|
declare class JsonSerializer implements CacheSerializer {
|
|
@@ -362,6 +376,7 @@ declare class RedisSingleFlightCoordinator implements CacheSingleFlightCoordinat
|
|
|
362
376
|
private readonly prefix;
|
|
363
377
|
constructor(options: RedisSingleFlightCoordinatorOptions);
|
|
364
378
|
execute<T>(key: string, options: CacheSingleFlightExecutionOptions, worker: () => Promise<T>, waiter: () => Promise<T>): Promise<T>;
|
|
379
|
+
private startLeaseRenewal;
|
|
365
380
|
}
|
|
366
381
|
|
|
367
382
|
declare class StampedeGuard {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InvalidationBus, C as CacheLogger, a as InvalidationMessage, b as CacheTagIndex, c as CacheStack, d as CacheWrapOptions, e as CacheGetOptions, f as CacheLayer, g as CacheSerializer, h as CacheLayerSetManyEntry, i as CacheSingleFlightCoordinator, j as CacheSingleFlightExecutionOptions } from './edge-
|
|
2
|
-
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheDegradationOptions, n as CacheHealthCheckResult, o as CacheHitRateSnapshot, p as CacheInspectResult, q as CacheLayerLatency, r as CacheMGetEntry, s as CacheMSetEntry, t as CacheMetricsSnapshot, u as CacheMissError, v as CacheNamespace, w as CacheRateLimitOptions, x as CacheSnapshotEntry, y as CacheStackEvents, z as CacheStackOptions, A as CacheStatsSnapshot, B as CacheTtlPolicy, D as CacheTtlPolicyContext, E as CacheWarmEntry, F as CacheWarmOptions, G as CacheWarmProgress, H as CacheWriteBehindOptions, J as CacheWriteOptions, K as EvictionPolicy, L as LayerTtlMap, M as MemoryLayer, N as MemoryLayerOptions, O as MemoryLayerSnapshotEntry, P as PatternMatcher, T as TagIndex, Q as createHonoCacheMiddleware } from './edge-
|
|
1
|
+
import { I as InvalidationBus, C as CacheLogger, a as InvalidationMessage, b as CacheTagIndex, c as CacheStack, d as CacheWrapOptions, e as CacheGetOptions, f as CacheLayer, g as CacheSerializer, h as CacheLayerSetManyEntry, i as CacheSingleFlightCoordinator, j as CacheSingleFlightExecutionOptions } from './edge-B_rUqDy6.js';
|
|
2
|
+
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheDegradationOptions, n as CacheHealthCheckResult, o as CacheHitRateSnapshot, p as CacheInspectResult, q as CacheLayerLatency, r as CacheMGetEntry, s as CacheMSetEntry, t as CacheMetricsSnapshot, u as CacheMissError, v as CacheNamespace, w as CacheRateLimitOptions, x as CacheSnapshotEntry, y as CacheStackEvents, z as CacheStackOptions, A as CacheStatsSnapshot, B as CacheTtlPolicy, D as CacheTtlPolicyContext, E as CacheWarmEntry, F as CacheWarmOptions, G as CacheWarmProgress, H as CacheWriteBehindOptions, J as CacheWriteOptions, K as EvictionPolicy, L as LayerTtlMap, M as MemoryLayer, N as MemoryLayerOptions, O as MemoryLayerSnapshotEntry, P as PatternMatcher, T as TagIndex, Q as createHonoCacheMiddleware } from './edge-B_rUqDy6.js';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
@@ -35,11 +35,13 @@ interface RedisTagIndexOptions {
|
|
|
35
35
|
client: Redis;
|
|
36
36
|
prefix?: string;
|
|
37
37
|
scanCount?: number;
|
|
38
|
+
knownKeysShards?: number;
|
|
38
39
|
}
|
|
39
40
|
declare class RedisTagIndex implements CacheTagIndex {
|
|
40
41
|
private readonly client;
|
|
41
42
|
private readonly prefix;
|
|
42
43
|
private readonly scanCount;
|
|
44
|
+
private readonly knownKeysShards;
|
|
43
45
|
constructor(options: RedisTagIndexOptions);
|
|
44
46
|
touch(key: string): Promise<void>;
|
|
45
47
|
track(key: string, tags: string[]): Promise<void>;
|
|
@@ -50,7 +52,8 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
50
52
|
matchPattern(pattern: string): Promise<string[]>;
|
|
51
53
|
clear(): Promise<void>;
|
|
52
54
|
private scanIndexKeys;
|
|
53
|
-
private
|
|
55
|
+
private knownKeysKeyFor;
|
|
56
|
+
private knownKeysKeys;
|
|
54
57
|
private keyTagsKey;
|
|
55
58
|
private tagKeysKey;
|
|
56
59
|
}
|
|
@@ -173,6 +176,11 @@ interface RedisLayerOptions {
|
|
|
173
176
|
scanCount?: number;
|
|
174
177
|
compression?: CompressionAlgorithm;
|
|
175
178
|
compressionThreshold?: number;
|
|
179
|
+
/**
|
|
180
|
+
* Maximum number of bytes allowed after decompression.
|
|
181
|
+
* Prevents decompression bomb attacks. Defaults to 64 MiB.
|
|
182
|
+
*/
|
|
183
|
+
decompressionMaxBytes?: number;
|
|
176
184
|
disconnectOnDispose?: boolean;
|
|
177
185
|
}
|
|
178
186
|
declare class RedisLayer implements CacheLayer {
|
|
@@ -186,6 +194,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
186
194
|
private readonly scanCount;
|
|
187
195
|
private readonly compression?;
|
|
188
196
|
private readonly compressionThreshold;
|
|
197
|
+
private readonly decompressionMaxBytes;
|
|
189
198
|
private readonly disconnectOnDispose;
|
|
190
199
|
constructor(options: RedisLayerOptions);
|
|
191
200
|
get<T>(key: string): Promise<T | null>;
|
|
@@ -219,6 +228,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
219
228
|
private encodePayload;
|
|
220
229
|
/**
|
|
221
230
|
* Decompresses the payload asynchronously if a compression header is present.
|
|
231
|
+
* Enforces a maximum decompressed size to prevent decompression bomb attacks.
|
|
222
232
|
*/
|
|
223
233
|
private decodePayload;
|
|
224
234
|
}
|
|
@@ -274,6 +284,9 @@ declare class DiskLayer implements CacheLayer {
|
|
|
274
284
|
ping(): Promise<boolean>;
|
|
275
285
|
dispose(): Promise<void>;
|
|
276
286
|
private keyToPath;
|
|
287
|
+
private resolveDirectory;
|
|
288
|
+
private normalizeMaxFiles;
|
|
289
|
+
private deserializeEntry;
|
|
277
290
|
private safeDelete;
|
|
278
291
|
private enqueueWrite;
|
|
279
292
|
/**
|
|
@@ -341,6 +354,7 @@ declare class MemcachedLayer implements CacheLayer {
|
|
|
341
354
|
deleteMany(keys: string[]): Promise<void>;
|
|
342
355
|
clear(): Promise<void>;
|
|
343
356
|
private withPrefix;
|
|
357
|
+
private validateKey;
|
|
344
358
|
}
|
|
345
359
|
|
|
346
360
|
declare class JsonSerializer implements CacheSerializer {
|
|
@@ -362,6 +376,7 @@ declare class RedisSingleFlightCoordinator implements CacheSingleFlightCoordinat
|
|
|
362
376
|
private readonly prefix;
|
|
363
377
|
constructor(options: RedisSingleFlightCoordinatorOptions);
|
|
364
378
|
execute<T>(key: string, options: CacheSingleFlightExecutionOptions, worker: () => Promise<T>, waiter: () => Promise<T>): Promise<T>;
|
|
379
|
+
private startLeaseRenewal;
|
|
365
380
|
}
|
|
366
381
|
|
|
367
382
|
declare class StampedeGuard {
|