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/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-C1sBhTfv.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-C1sBhTfv.cjs';
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 knownKeysKey;
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-C1sBhTfv.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-C1sBhTfv.js';
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 knownKeysKey;
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 {