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/README.md +11 -4
- package/benchmarks/direct.ts +221 -0
- package/benchmarks/edge-utils.ts +28 -0
- package/benchmarks/edge.ts +491 -0
- package/benchmarks/http.ts +99 -0
- package/benchmarks/memory-pressure.ts +144 -0
- package/benchmarks/multi-process-fanout.ts +231 -0
- package/benchmarks/multi-process-worker.ts +151 -0
- package/benchmarks/paths.ts +25 -0
- package/benchmarks/queue-amplification-utils.ts +48 -0
- package/benchmarks/queue-amplification.ts +230 -0
- package/benchmarks/redis-latency-proxy.ts +100 -0
- package/benchmarks/redis.ts +107 -0
- package/benchmarks/scenario-utils.ts +38 -0
- package/benchmarks/server.ts +157 -0
- package/benchmarks/slow-redis-latency.ts +309 -0
- package/benchmarks/slow-redis-utils.ts +29 -0
- package/benchmarks/slow-redis.ts +47 -0
- package/benchmarks/stats.ts +46 -0
- package/benchmarks/workload.ts +77 -0
- package/dist/cli.cjs +14 -1
- package/dist/cli.js +14 -1
- package/dist/{edge-DBs8Ko5W.d.cts → edge-BXWTKlI1.d.cts} +1 -0
- package/dist/{edge-DBs8Ko5W.d.ts → edge-BXWTKlI1.d.ts} +1 -0
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/index.cjs +304 -112
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +301 -109
- package/package.json +12 -2
- package/packages/nestjs/dist/index.cjs +146 -68
- package/packages/nestjs/dist/index.d.cts +1 -0
- package/packages/nestjs/dist/index.d.ts +1 -0
- package/packages/nestjs/dist/index.js +146 -68
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-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
|
|
433
|
+
private readonly inFlight;
|
|
421
434
|
execute<T>(key: string, task: () => Promise<T>): Promise<T>;
|
|
422
|
-
private
|
|
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-
|
|
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-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
|
|
433
|
+
private readonly inFlight;
|
|
421
434
|
execute<T>(key: string, task: () => Promise<T>): Promise<T>;
|
|
422
|
-
private
|
|
435
|
+
private releaseEntry;
|
|
423
436
|
}
|
|
424
437
|
|
|
425
438
|
/**
|