layercache 2.1.0 → 3.1.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 +29 -9
- package/dist/{chunk-6X7NV5BG.js → chunk-L6L7QXYF.js} +95 -14
- package/dist/{chunk-IVX6ABFX.js → chunk-XMUT66SH.js} +116 -90
- package/dist/cli.cjs +153 -25
- package/dist/cli.js +69 -13
- package/dist/{edge-BCU8D-Yd.d.cts → edge-LBUuZAdr.d.cts} +61 -2
- package/dist/{edge-BCU8D-Yd.d.ts → edge-LBUuZAdr.d.ts} +61 -2
- package/dist/edge.cjs +114 -90
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +1 -1
- package/dist/index.cjs +578 -220
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +366 -113
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
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 CacheContextOptionsContext, n as CacheDegradationOptions, o as
|
|
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-LBUuZAdr.cjs';
|
|
2
|
+
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheContextOptionsContext, n as CacheDegradationOptions, o as CacheEntryResult, p as CacheEntryWriteKind, q as CacheEntryWriteOptions, r as CacheFetcher, s as CacheFetcherContext, t as CacheHealthCheckResult, u as CacheHitRateSnapshot, v as CacheInspectResult, w as CacheLayerLatency, x as CacheMGetEntry, y as CacheMSetEntry, z as CacheMetricsSnapshot, A as CacheMissError, B as CacheNamespace, D as CacheRateLimitOptions, E as CacheSnapshotEntry, F as CacheStackEvents, G as CacheStackOptions, H as CacheStatsSnapshot, J as CacheTtlPolicy, K as CacheTtlPolicyContext, L as CacheWarmEntry, M as CacheWarmOptions, N as CacheWarmProgress, O as CacheWriteBehindOptions, P as CacheWriteOptions, Q as EvictionPolicy, R as LayerTtlMap, S as MemoryLayer, T as MemoryLayerOptions, U as MemoryLayerSnapshotEntry, V as PatternMatcher, W as TagIndex, X as createHonoCacheMiddleware } from './edge-LBUuZAdr.cjs';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
6
|
+
interface RedisGenerationClient {
|
|
7
|
+
get(key: string): Promise<string | null>;
|
|
8
|
+
set(key: string, value: string, mode?: 'NX'): Promise<unknown>;
|
|
9
|
+
incr(key: string): Promise<number>;
|
|
10
|
+
}
|
|
11
|
+
interface RedisGenerationStoreOptions {
|
|
12
|
+
/** Redis client used to persist and atomically bump the generation. */
|
|
13
|
+
client: RedisGenerationClient;
|
|
14
|
+
/** Redis key storing the active generation. Defaults to `layercache:generation`. */
|
|
15
|
+
key?: string;
|
|
16
|
+
}
|
|
17
|
+
declare class RedisGenerationStore {
|
|
18
|
+
private readonly client;
|
|
19
|
+
private readonly key;
|
|
20
|
+
constructor(options: RedisGenerationStoreOptions);
|
|
21
|
+
get(): Promise<number | undefined>;
|
|
22
|
+
getOrInitialize(initialGeneration?: number): Promise<number>;
|
|
23
|
+
set(generation: number): Promise<void>;
|
|
24
|
+
bump(): Promise<number>;
|
|
25
|
+
private parseGeneration;
|
|
26
|
+
private assertGeneration;
|
|
27
|
+
private isGeneration;
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
interface RedisInvalidationBusOptions {
|
|
7
31
|
/** Redis client used to publish invalidation messages. */
|
|
8
32
|
publisher: Redis;
|
|
@@ -10,6 +34,11 @@ interface RedisInvalidationBusOptions {
|
|
|
10
34
|
subscriber?: Redis;
|
|
11
35
|
/** Pub/sub channel name. Defaults to `layercache:invalidation`. */
|
|
12
36
|
channel?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional shared secret used to sign and verify invalidation messages.
|
|
39
|
+
* When configured, unsigned or invalidly signed messages are rejected.
|
|
40
|
+
*/
|
|
41
|
+
signingSecret?: string | Buffer;
|
|
13
42
|
/** Optional logger for invalid payloads or subscriber errors. */
|
|
14
43
|
logger?: CacheLogger;
|
|
15
44
|
}
|
|
@@ -25,6 +54,7 @@ declare class RedisInvalidationBus implements InvalidationBus {
|
|
|
25
54
|
private readonly publisher;
|
|
26
55
|
private readonly subscriber;
|
|
27
56
|
private readonly logger?;
|
|
57
|
+
private readonly signingKey?;
|
|
28
58
|
private readonly handlers;
|
|
29
59
|
private sharedListener?;
|
|
30
60
|
private subscribePromise;
|
|
@@ -39,6 +69,9 @@ declare class RedisInvalidationBus implements InvalidationBus {
|
|
|
39
69
|
publish(message: InvalidationMessage): Promise<void>;
|
|
40
70
|
private dispatchToHandlers;
|
|
41
71
|
private isInvalidationMessage;
|
|
72
|
+
private signMessage;
|
|
73
|
+
private verifySignedEnvelope;
|
|
74
|
+
private createSignature;
|
|
42
75
|
private reportError;
|
|
43
76
|
}
|
|
44
77
|
|
|
@@ -51,12 +84,19 @@ interface RedisTagIndexOptions {
|
|
|
51
84
|
scanCount?: number;
|
|
52
85
|
/** Number of shards for known-key sets. Defaults to 16. */
|
|
53
86
|
knownKeysShards?: number;
|
|
87
|
+
/** Optional logger for legacy index warnings. */
|
|
88
|
+
logger?: CacheLogger;
|
|
89
|
+
}
|
|
90
|
+
interface RedisTagIndexMigrationResult {
|
|
91
|
+
migratedKeys: number;
|
|
54
92
|
}
|
|
55
93
|
declare class RedisTagIndex implements CacheTagIndex {
|
|
56
94
|
private readonly client;
|
|
57
95
|
private readonly prefix;
|
|
58
96
|
private readonly scanCount;
|
|
59
97
|
private readonly knownKeysShards;
|
|
98
|
+
private readonly logger?;
|
|
99
|
+
private warnedLegacyKnownKeys;
|
|
60
100
|
constructor(options: RedisTagIndexOptions);
|
|
61
101
|
/**
|
|
62
102
|
* Records a key as known without changing tag assignments.
|
|
@@ -102,9 +142,13 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
102
142
|
* Clears all Redis tag-index state under this prefix.
|
|
103
143
|
*/
|
|
104
144
|
clear(): Promise<void>;
|
|
145
|
+
migrateLegacyKnownKeys(): Promise<RedisTagIndexMigrationResult>;
|
|
105
146
|
private scanIndexKeys;
|
|
106
147
|
private knownKeysKeyFor;
|
|
148
|
+
private knownKeysKeysForRead;
|
|
107
149
|
private knownKeysKeys;
|
|
150
|
+
private legacyKnownKeysKey;
|
|
151
|
+
private warnLegacyKnownKeys;
|
|
108
152
|
private keyTagsKey;
|
|
109
153
|
private tagKeysKey;
|
|
110
154
|
}
|
|
@@ -436,6 +480,11 @@ interface DiskLayerOptions {
|
|
|
436
480
|
* Set to `false` to disable the limit.
|
|
437
481
|
*/
|
|
438
482
|
maxEntryBytes?: number | false;
|
|
483
|
+
/**
|
|
484
|
+
* Maximum pending write operations allowed in the serialized write queue.
|
|
485
|
+
* Defaults to 10,000. Set to `false` to disable the guard.
|
|
486
|
+
*/
|
|
487
|
+
maxWriteQueueDepth?: number | false;
|
|
439
488
|
/**
|
|
440
489
|
* Encrypt cached data at rest using AES-256-GCM. Accepts a string or Buffer.
|
|
441
490
|
* The key material is hashed with SHA-256 to derive the actual cipher key.
|
|
@@ -469,8 +518,10 @@ declare class DiskLayer implements CacheLayer {
|
|
|
469
518
|
private readonly serializer;
|
|
470
519
|
private readonly maxFiles;
|
|
471
520
|
private readonly maxEntryBytes;
|
|
521
|
+
private readonly maxWriteQueueDepth;
|
|
472
522
|
private readonly protection;
|
|
473
523
|
private writeQueue;
|
|
524
|
+
private writeQueueDepth;
|
|
474
525
|
/**
|
|
475
526
|
* Creates a disk-backed cache layer.
|
|
476
527
|
*/
|
|
@@ -540,6 +591,7 @@ declare class DiskLayer implements CacheLayer {
|
|
|
540
591
|
private resolveDirectory;
|
|
541
592
|
private normalizeMaxFiles;
|
|
542
593
|
private normalizeMaxEntryBytes;
|
|
594
|
+
private normalizeMaxWriteQueueDepth;
|
|
543
595
|
private readEntryFile;
|
|
544
596
|
private readHandleWithLimit;
|
|
545
597
|
private scanEntries;
|
|
@@ -746,4 +798,4 @@ declare function createPrometheusMetricsExporter(stacks: CacheStack | Array<{
|
|
|
746
798
|
name: string;
|
|
747
799
|
}>): () => string;
|
|
748
800
|
|
|
749
|
-
export { CacheGetOptions, CacheLayer, CacheLayerSetManyEntry, CacheLogger, CacheSerializer, CacheSingleFlightCoordinator, CacheSingleFlightExecutionOptions, CacheStack, CacheTagIndex, CacheWrapOptions, DiskLayer, InvalidationBus, InvalidationMessage, JsonSerializer, type MemcachedClient, MemcachedLayer, MsgpackSerializer, RedisInvalidationBus, RedisLayer, RedisSingleFlightCoordinator, RedisTagIndex, StampedeGuard, cacheGraphqlResolver, createCacheStatsHandler, createCachedMethodDecorator, createExpressCacheMiddleware, createFastifyLayercachePlugin, createOpenTelemetryPlugin, createPrometheusMetricsExporter, createTrpcCacheMiddleware };
|
|
801
|
+
export { CacheGetOptions, CacheLayer, CacheLayerSetManyEntry, CacheLogger, CacheSerializer, CacheSingleFlightCoordinator, CacheSingleFlightExecutionOptions, CacheStack, CacheTagIndex, CacheWrapOptions, DiskLayer, InvalidationBus, InvalidationMessage, JsonSerializer, type MemcachedClient, MemcachedLayer, MsgpackSerializer, RedisGenerationStore, RedisInvalidationBus, RedisLayer, RedisSingleFlightCoordinator, RedisTagIndex, StampedeGuard, cacheGraphqlResolver, createCacheStatsHandler, createCachedMethodDecorator, createExpressCacheMiddleware, createFastifyLayercachePlugin, createOpenTelemetryPlugin, createPrometheusMetricsExporter, createTrpcCacheMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
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 CacheContextOptionsContext, n as CacheDegradationOptions, o as
|
|
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-LBUuZAdr.js';
|
|
2
|
+
export { k as CacheAdaptiveTtlOptions, l as CacheCircuitBreakerOptions, m as CacheContextOptionsContext, n as CacheDegradationOptions, o as CacheEntryResult, p as CacheEntryWriteKind, q as CacheEntryWriteOptions, r as CacheFetcher, s as CacheFetcherContext, t as CacheHealthCheckResult, u as CacheHitRateSnapshot, v as CacheInspectResult, w as CacheLayerLatency, x as CacheMGetEntry, y as CacheMSetEntry, z as CacheMetricsSnapshot, A as CacheMissError, B as CacheNamespace, D as CacheRateLimitOptions, E as CacheSnapshotEntry, F as CacheStackEvents, G as CacheStackOptions, H as CacheStatsSnapshot, J as CacheTtlPolicy, K as CacheTtlPolicyContext, L as CacheWarmEntry, M as CacheWarmOptions, N as CacheWarmProgress, O as CacheWriteBehindOptions, P as CacheWriteOptions, Q as EvictionPolicy, R as LayerTtlMap, S as MemoryLayer, T as MemoryLayerOptions, U as MemoryLayerSnapshotEntry, V as PatternMatcher, W as TagIndex, X as createHonoCacheMiddleware } from './edge-LBUuZAdr.js';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
6
|
+
interface RedisGenerationClient {
|
|
7
|
+
get(key: string): Promise<string | null>;
|
|
8
|
+
set(key: string, value: string, mode?: 'NX'): Promise<unknown>;
|
|
9
|
+
incr(key: string): Promise<number>;
|
|
10
|
+
}
|
|
11
|
+
interface RedisGenerationStoreOptions {
|
|
12
|
+
/** Redis client used to persist and atomically bump the generation. */
|
|
13
|
+
client: RedisGenerationClient;
|
|
14
|
+
/** Redis key storing the active generation. Defaults to `layercache:generation`. */
|
|
15
|
+
key?: string;
|
|
16
|
+
}
|
|
17
|
+
declare class RedisGenerationStore {
|
|
18
|
+
private readonly client;
|
|
19
|
+
private readonly key;
|
|
20
|
+
constructor(options: RedisGenerationStoreOptions);
|
|
21
|
+
get(): Promise<number | undefined>;
|
|
22
|
+
getOrInitialize(initialGeneration?: number): Promise<number>;
|
|
23
|
+
set(generation: number): Promise<void>;
|
|
24
|
+
bump(): Promise<number>;
|
|
25
|
+
private parseGeneration;
|
|
26
|
+
private assertGeneration;
|
|
27
|
+
private isGeneration;
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
interface RedisInvalidationBusOptions {
|
|
7
31
|
/** Redis client used to publish invalidation messages. */
|
|
8
32
|
publisher: Redis;
|
|
@@ -10,6 +34,11 @@ interface RedisInvalidationBusOptions {
|
|
|
10
34
|
subscriber?: Redis;
|
|
11
35
|
/** Pub/sub channel name. Defaults to `layercache:invalidation`. */
|
|
12
36
|
channel?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional shared secret used to sign and verify invalidation messages.
|
|
39
|
+
* When configured, unsigned or invalidly signed messages are rejected.
|
|
40
|
+
*/
|
|
41
|
+
signingSecret?: string | Buffer;
|
|
13
42
|
/** Optional logger for invalid payloads or subscriber errors. */
|
|
14
43
|
logger?: CacheLogger;
|
|
15
44
|
}
|
|
@@ -25,6 +54,7 @@ declare class RedisInvalidationBus implements InvalidationBus {
|
|
|
25
54
|
private readonly publisher;
|
|
26
55
|
private readonly subscriber;
|
|
27
56
|
private readonly logger?;
|
|
57
|
+
private readonly signingKey?;
|
|
28
58
|
private readonly handlers;
|
|
29
59
|
private sharedListener?;
|
|
30
60
|
private subscribePromise;
|
|
@@ -39,6 +69,9 @@ declare class RedisInvalidationBus implements InvalidationBus {
|
|
|
39
69
|
publish(message: InvalidationMessage): Promise<void>;
|
|
40
70
|
private dispatchToHandlers;
|
|
41
71
|
private isInvalidationMessage;
|
|
72
|
+
private signMessage;
|
|
73
|
+
private verifySignedEnvelope;
|
|
74
|
+
private createSignature;
|
|
42
75
|
private reportError;
|
|
43
76
|
}
|
|
44
77
|
|
|
@@ -51,12 +84,19 @@ interface RedisTagIndexOptions {
|
|
|
51
84
|
scanCount?: number;
|
|
52
85
|
/** Number of shards for known-key sets. Defaults to 16. */
|
|
53
86
|
knownKeysShards?: number;
|
|
87
|
+
/** Optional logger for legacy index warnings. */
|
|
88
|
+
logger?: CacheLogger;
|
|
89
|
+
}
|
|
90
|
+
interface RedisTagIndexMigrationResult {
|
|
91
|
+
migratedKeys: number;
|
|
54
92
|
}
|
|
55
93
|
declare class RedisTagIndex implements CacheTagIndex {
|
|
56
94
|
private readonly client;
|
|
57
95
|
private readonly prefix;
|
|
58
96
|
private readonly scanCount;
|
|
59
97
|
private readonly knownKeysShards;
|
|
98
|
+
private readonly logger?;
|
|
99
|
+
private warnedLegacyKnownKeys;
|
|
60
100
|
constructor(options: RedisTagIndexOptions);
|
|
61
101
|
/**
|
|
62
102
|
* Records a key as known without changing tag assignments.
|
|
@@ -102,9 +142,13 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
102
142
|
* Clears all Redis tag-index state under this prefix.
|
|
103
143
|
*/
|
|
104
144
|
clear(): Promise<void>;
|
|
145
|
+
migrateLegacyKnownKeys(): Promise<RedisTagIndexMigrationResult>;
|
|
105
146
|
private scanIndexKeys;
|
|
106
147
|
private knownKeysKeyFor;
|
|
148
|
+
private knownKeysKeysForRead;
|
|
107
149
|
private knownKeysKeys;
|
|
150
|
+
private legacyKnownKeysKey;
|
|
151
|
+
private warnLegacyKnownKeys;
|
|
108
152
|
private keyTagsKey;
|
|
109
153
|
private tagKeysKey;
|
|
110
154
|
}
|
|
@@ -436,6 +480,11 @@ interface DiskLayerOptions {
|
|
|
436
480
|
* Set to `false` to disable the limit.
|
|
437
481
|
*/
|
|
438
482
|
maxEntryBytes?: number | false;
|
|
483
|
+
/**
|
|
484
|
+
* Maximum pending write operations allowed in the serialized write queue.
|
|
485
|
+
* Defaults to 10,000. Set to `false` to disable the guard.
|
|
486
|
+
*/
|
|
487
|
+
maxWriteQueueDepth?: number | false;
|
|
439
488
|
/**
|
|
440
489
|
* Encrypt cached data at rest using AES-256-GCM. Accepts a string or Buffer.
|
|
441
490
|
* The key material is hashed with SHA-256 to derive the actual cipher key.
|
|
@@ -469,8 +518,10 @@ declare class DiskLayer implements CacheLayer {
|
|
|
469
518
|
private readonly serializer;
|
|
470
519
|
private readonly maxFiles;
|
|
471
520
|
private readonly maxEntryBytes;
|
|
521
|
+
private readonly maxWriteQueueDepth;
|
|
472
522
|
private readonly protection;
|
|
473
523
|
private writeQueue;
|
|
524
|
+
private writeQueueDepth;
|
|
474
525
|
/**
|
|
475
526
|
* Creates a disk-backed cache layer.
|
|
476
527
|
*/
|
|
@@ -540,6 +591,7 @@ declare class DiskLayer implements CacheLayer {
|
|
|
540
591
|
private resolveDirectory;
|
|
541
592
|
private normalizeMaxFiles;
|
|
542
593
|
private normalizeMaxEntryBytes;
|
|
594
|
+
private normalizeMaxWriteQueueDepth;
|
|
543
595
|
private readEntryFile;
|
|
544
596
|
private readHandleWithLimit;
|
|
545
597
|
private scanEntries;
|
|
@@ -746,4 +798,4 @@ declare function createPrometheusMetricsExporter(stacks: CacheStack | Array<{
|
|
|
746
798
|
name: string;
|
|
747
799
|
}>): () => string;
|
|
748
800
|
|
|
749
|
-
export { CacheGetOptions, CacheLayer, CacheLayerSetManyEntry, CacheLogger, CacheSerializer, CacheSingleFlightCoordinator, CacheSingleFlightExecutionOptions, CacheStack, CacheTagIndex, CacheWrapOptions, DiskLayer, InvalidationBus, InvalidationMessage, JsonSerializer, type MemcachedClient, MemcachedLayer, MsgpackSerializer, RedisInvalidationBus, RedisLayer, RedisSingleFlightCoordinator, RedisTagIndex, StampedeGuard, cacheGraphqlResolver, createCacheStatsHandler, createCachedMethodDecorator, createExpressCacheMiddleware, createFastifyLayercachePlugin, createOpenTelemetryPlugin, createPrometheusMetricsExporter, createTrpcCacheMiddleware };
|
|
801
|
+
export { CacheGetOptions, CacheLayer, CacheLayerSetManyEntry, CacheLogger, CacheSerializer, CacheSingleFlightCoordinator, CacheSingleFlightExecutionOptions, CacheStack, CacheTagIndex, CacheWrapOptions, DiskLayer, InvalidationBus, InvalidationMessage, JsonSerializer, type MemcachedClient, MemcachedLayer, MsgpackSerializer, RedisGenerationStore, RedisInvalidationBus, RedisLayer, RedisSingleFlightCoordinator, RedisTagIndex, StampedeGuard, cacheGraphqlResolver, createCacheStatsHandler, createCachedMethodDecorator, createExpressCacheMiddleware, createFastifyLayercachePlugin, createOpenTelemetryPlugin, createPrometheusMetricsExporter, createTrpcCacheMiddleware };
|