layercache 1.2.8 → 1.3.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/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-DBs8Ko5W.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-DBs8Ko5W.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-BXWTKlI1.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-BXWTKlI1.cjs';
3
3
  import Redis from 'ioredis';
4
4
  import 'node:events';
5
5
 
@@ -23,6 +23,7 @@ declare class RedisInvalidationBus implements InvalidationBus {
23
23
  private readonly logger?;
24
24
  private readonly handlers;
25
25
  private sharedListener?;
26
+ private subscribePromise;
26
27
  constructor(options: RedisInvalidationBusOptions);
27
28
  subscribe(handler: (message: InvalidationMessage) => Promise<void> | void): Promise<() => Promise<void>>;
28
29
  publish(message: InvalidationMessage): Promise<void>;
@@ -202,6 +203,11 @@ interface RedisLayerOptions {
202
203
  * Prevents decompression bomb attacks. Defaults to 64 MiB.
203
204
  */
204
205
  decompressionMaxBytes?: number;
206
+ /**
207
+ * Per-command timeout in milliseconds for Redis round-trips.
208
+ * Slow commands reject so CacheStack can treat the layer as degraded.
209
+ */
210
+ commandTimeoutMs?: number;
205
211
  disconnectOnDispose?: boolean;
206
212
  }
207
213
  declare class RedisLayer implements CacheLayer {
@@ -216,6 +222,7 @@ declare class RedisLayer implements CacheLayer {
216
222
  private readonly compression?;
217
223
  private readonly compressionThreshold;
218
224
  private readonly decompressionMaxBytes;
225
+ private readonly commandTimeoutMs;
219
226
  private readonly disconnectOnDispose;
220
227
  constructor(options: RedisLayerOptions);
221
228
  get<T>(key: string): Promise<T | null>;
@@ -255,6 +262,8 @@ declare class RedisLayer implements CacheLayer {
255
262
  */
256
263
  private decodePayload;
257
264
  private decompressWithLimit;
265
+ private normalizeCommandTimeoutMs;
266
+ private runCommand;
258
267
  }
259
268
 
260
269
  interface DiskLayerOptions {
@@ -407,19 +416,23 @@ declare class MsgpackSerializer implements CacheSerializer {
407
416
  interface RedisSingleFlightCoordinatorOptions {
408
417
  client: Redis;
409
418
  prefix?: string;
419
+ commandTimeoutMs?: number;
410
420
  }
411
421
  declare class RedisSingleFlightCoordinator implements CacheSingleFlightCoordinator {
412
422
  private readonly client;
413
423
  private readonly prefix;
424
+ private readonly commandTimeoutMs;
414
425
  constructor(options: RedisSingleFlightCoordinatorOptions);
415
426
  execute<T>(key: string, options: CacheSingleFlightExecutionOptions, worker: () => Promise<T>, waiter: () => Promise<T>): Promise<T>;
416
427
  private startLeaseRenewal;
428
+ private normalizeCommandTimeoutMs;
429
+ private runCommand;
417
430
  }
418
431
 
419
432
  declare class StampedeGuard {
420
- private readonly mutexes;
433
+ private readonly inFlight;
421
434
  execute<T>(key: string, task: () => Promise<T>): Promise<T>;
422
- private getMutexEntry;
435
+ private releaseEntry;
423
436
  }
424
437
 
425
438
  /**
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-DBs8Ko5W.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-DBs8Ko5W.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-BXWTKlI1.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-BXWTKlI1.js';
3
3
  import Redis from 'ioredis';
4
4
  import 'node:events';
5
5
 
@@ -23,6 +23,7 @@ declare class RedisInvalidationBus implements InvalidationBus {
23
23
  private readonly logger?;
24
24
  private readonly handlers;
25
25
  private sharedListener?;
26
+ private subscribePromise;
26
27
  constructor(options: RedisInvalidationBusOptions);
27
28
  subscribe(handler: (message: InvalidationMessage) => Promise<void> | void): Promise<() => Promise<void>>;
28
29
  publish(message: InvalidationMessage): Promise<void>;
@@ -202,6 +203,11 @@ interface RedisLayerOptions {
202
203
  * Prevents decompression bomb attacks. Defaults to 64 MiB.
203
204
  */
204
205
  decompressionMaxBytes?: number;
206
+ /**
207
+ * Per-command timeout in milliseconds for Redis round-trips.
208
+ * Slow commands reject so CacheStack can treat the layer as degraded.
209
+ */
210
+ commandTimeoutMs?: number;
205
211
  disconnectOnDispose?: boolean;
206
212
  }
207
213
  declare class RedisLayer implements CacheLayer {
@@ -216,6 +222,7 @@ declare class RedisLayer implements CacheLayer {
216
222
  private readonly compression?;
217
223
  private readonly compressionThreshold;
218
224
  private readonly decompressionMaxBytes;
225
+ private readonly commandTimeoutMs;
219
226
  private readonly disconnectOnDispose;
220
227
  constructor(options: RedisLayerOptions);
221
228
  get<T>(key: string): Promise<T | null>;
@@ -255,6 +262,8 @@ declare class RedisLayer implements CacheLayer {
255
262
  */
256
263
  private decodePayload;
257
264
  private decompressWithLimit;
265
+ private normalizeCommandTimeoutMs;
266
+ private runCommand;
258
267
  }
259
268
 
260
269
  interface DiskLayerOptions {
@@ -407,19 +416,23 @@ declare class MsgpackSerializer implements CacheSerializer {
407
416
  interface RedisSingleFlightCoordinatorOptions {
408
417
  client: Redis;
409
418
  prefix?: string;
419
+ commandTimeoutMs?: number;
410
420
  }
411
421
  declare class RedisSingleFlightCoordinator implements CacheSingleFlightCoordinator {
412
422
  private readonly client;
413
423
  private readonly prefix;
424
+ private readonly commandTimeoutMs;
414
425
  constructor(options: RedisSingleFlightCoordinatorOptions);
415
426
  execute<T>(key: string, options: CacheSingleFlightExecutionOptions, worker: () => Promise<T>, waiter: () => Promise<T>): Promise<T>;
416
427
  private startLeaseRenewal;
428
+ private normalizeCommandTimeoutMs;
429
+ private runCommand;
417
430
  }
418
431
 
419
432
  declare class StampedeGuard {
420
- private readonly mutexes;
433
+ private readonly inFlight;
421
434
  execute<T>(key: string, task: () => Promise<T>): Promise<T>;
422
- private getMutexEntry;
435
+ private releaseEntry;
423
436
  }
424
437
 
425
438
  /**