layercache 1.2.5 → 1.2.6
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/LICENSE +190 -21
- package/README.md +254 -912
- package/dist/{chunk-7V7XAB74.js → chunk-4PPBOOXT.js} +37 -3
- package/dist/{chunk-QHWG7QS5.js → chunk-BQLL6IM5.js} +47 -1
- package/dist/{chunk-JC26W3KK.js → chunk-GJBKCFE6.js} +38 -3
- package/dist/cli.cjs +83 -3
- package/dist/cli.js +2 -2
- package/dist/{edge-P07GCO2Y.d.ts → edge-DLstcDMn.d.cts} +32 -14
- package/dist/{edge-P07GCO2Y.d.cts → edge-DLstcDMn.d.ts} +32 -14
- package/dist/edge.cjs +74 -5
- package/dist/edge.d.cts +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +2 -2
- package/dist/index.cjs +1070 -352
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +950 -347
- package/package.json +29 -3
- package/packages/nestjs/dist/index.cjs +722 -272
- package/packages/nestjs/dist/index.d.cts +23 -13
- package/packages/nestjs/dist/index.d.ts +23 -13
- package/packages/nestjs/dist/index.js +722 -272
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-DLstcDMn.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-DLstcDMn.cjs';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
@@ -47,9 +47,12 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
47
47
|
track(key: string, tags: string[]): Promise<void>;
|
|
48
48
|
remove(key: string): Promise<void>;
|
|
49
49
|
keysForTag(tag: string): Promise<string[]>;
|
|
50
|
+
forEachKeyForTag(tag: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
50
51
|
keysForPrefix(prefix: string): Promise<string[]>;
|
|
52
|
+
forEachKeyForPrefix(prefix: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
51
53
|
tagsForKey(key: string): Promise<string[]>;
|
|
52
54
|
matchPattern(pattern: string): Promise<string[]>;
|
|
55
|
+
forEachKeyMatchingPattern(pattern: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
53
56
|
clear(): Promise<void>;
|
|
54
57
|
private scanIndexKeys;
|
|
55
58
|
private knownKeysKeyFor;
|
|
@@ -58,7 +61,12 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
58
61
|
private tagKeysKey;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
interface CacheStatsHandlerOptions {
|
|
65
|
+
allowPublicAccess?: boolean;
|
|
66
|
+
authorize?: (request: unknown) => boolean | Promise<boolean>;
|
|
67
|
+
unauthorizedStatusCode?: number;
|
|
68
|
+
}
|
|
69
|
+
declare function createCacheStatsHandler(cache: CacheStack, options?: CacheStatsHandlerOptions): (request: unknown, response: {
|
|
62
70
|
setHeader?: (name: string, value: string) => void;
|
|
63
71
|
end: (body: string) => void;
|
|
64
72
|
statusCode?: number;
|
|
@@ -72,11 +80,19 @@ declare function createCachedMethodDecorator<TArgs extends unknown[] = unknown[]
|
|
|
72
80
|
|
|
73
81
|
interface FastifyLike {
|
|
74
82
|
decorate: (name: string, value: unknown) => void;
|
|
75
|
-
get?: (path: string, handler: () => unknown | Promise<unknown>) => void;
|
|
83
|
+
get?: (path: string, handler: (request: unknown, reply: FastifyLikeReply) => unknown | Promise<unknown>) => void;
|
|
84
|
+
}
|
|
85
|
+
interface FastifyLikeReply {
|
|
86
|
+
header?: (name: string, value: string) => unknown;
|
|
87
|
+
send?: (body: unknown) => unknown;
|
|
88
|
+
statusCode?: number;
|
|
76
89
|
}
|
|
77
90
|
interface FastifyLayercachePluginOptions {
|
|
78
91
|
exposeStatsRoute?: boolean;
|
|
79
92
|
statsPath?: string;
|
|
93
|
+
allowPublicStatsRoute?: boolean;
|
|
94
|
+
authorizeStatsRoute?: (request: unknown) => boolean | Promise<boolean>;
|
|
95
|
+
unauthorizedStatusCode?: number;
|
|
80
96
|
}
|
|
81
97
|
declare function createFastifyLayercachePlugin(cache: CacheStack, options?: FastifyLayercachePluginOptions): (fastify: FastifyLike) => Promise<void>;
|
|
82
98
|
|
|
@@ -86,6 +102,8 @@ interface ExpressLikeRequest {
|
|
|
86
102
|
originalUrl?: string;
|
|
87
103
|
path?: string;
|
|
88
104
|
query?: Record<string, unknown>;
|
|
105
|
+
headers?: Headers | Record<string, unknown>;
|
|
106
|
+
get?: (name: string) => string | undefined | null;
|
|
89
107
|
}
|
|
90
108
|
interface ExpressLikeResponse {
|
|
91
109
|
statusCode?: number;
|
|
@@ -104,6 +122,8 @@ interface ExpressCacheMiddlewareOptions extends CacheGetOptions {
|
|
|
104
122
|
* Only cache responses for these HTTP methods. Defaults to `['GET']`.
|
|
105
123
|
*/
|
|
106
124
|
methods?: string[];
|
|
125
|
+
/** Explicitly allow URL-only implicit cache keys. Disabled by default. */
|
|
126
|
+
allowPrivateCaching?: boolean;
|
|
107
127
|
}
|
|
108
128
|
/**
|
|
109
129
|
* Express/Connect-compatible middleware that caches JSON responses.
|
|
@@ -124,6 +144,7 @@ declare function createExpressCacheMiddleware(cache: CacheStack, options?: Expre
|
|
|
124
144
|
|
|
125
145
|
interface GraphqlCacheOptions<TArgs extends unknown[]> extends CacheGetOptions {
|
|
126
146
|
keyResolver?: (...args: TArgs) => string;
|
|
147
|
+
allowImplicitContextCaching?: boolean;
|
|
127
148
|
}
|
|
128
149
|
declare function cacheGraphqlResolver<TArgs extends unknown[], TResult>(cache: CacheStack, prefix: string, resolver: (...args: TArgs) => Promise<TResult>, options?: GraphqlCacheOptions<TArgs>): (...args: TArgs) => Promise<TResult | null>;
|
|
129
150
|
|
|
@@ -159,6 +180,7 @@ interface TrpcCacheMiddlewareContext<TInput = unknown, TResult = unknown> {
|
|
|
159
180
|
}
|
|
160
181
|
interface TrpcCacheMiddlewareOptions<TInput> extends CacheGetOptions {
|
|
161
182
|
keyResolver?: (input: TInput, path?: string, type?: string) => string;
|
|
183
|
+
allowImplicitContextCaching?: boolean;
|
|
162
184
|
}
|
|
163
185
|
declare function createTrpcCacheMiddleware<TInput = unknown, TResult = unknown>(cache: CacheStack, prefix: string, options?: TrpcCacheMiddlewareOptions<TInput>): (context: TrpcCacheMiddlewareContext<TInput, TResult>) => Promise<{
|
|
164
186
|
ok: boolean;
|
|
@@ -215,9 +237,11 @@ declare class RedisLayer implements CacheLayer {
|
|
|
215
237
|
*/
|
|
216
238
|
clear(): Promise<void>;
|
|
217
239
|
keys(): Promise<string[]>;
|
|
240
|
+
forEachKey(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
218
241
|
private scanKeys;
|
|
219
242
|
private withPrefix;
|
|
220
243
|
private deserializeOrDelete;
|
|
244
|
+
private deleteCorruptedKey;
|
|
221
245
|
private rewriteWithPrimarySerializer;
|
|
222
246
|
private primarySerializer;
|
|
223
247
|
private isSerializablePayload;
|
|
@@ -231,6 +255,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
231
255
|
* Enforces a maximum decompressed size to prevent decompression bomb attacks.
|
|
232
256
|
*/
|
|
233
257
|
private decodePayload;
|
|
258
|
+
private decompressWithLimit;
|
|
234
259
|
}
|
|
235
260
|
|
|
236
261
|
interface DiskLayerOptions {
|
|
@@ -244,6 +269,12 @@ interface DiskLayerOptions {
|
|
|
244
269
|
* Defaults to unlimited.
|
|
245
270
|
*/
|
|
246
271
|
maxFiles?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Maximum size, in bytes, of a single cache file that this layer will read.
|
|
274
|
+
* Oversized entries are treated as corrupted and removed. Defaults to 16 MiB.
|
|
275
|
+
* Set to `false` to disable the limit.
|
|
276
|
+
*/
|
|
277
|
+
maxEntryBytes?: number | false;
|
|
247
278
|
}
|
|
248
279
|
/**
|
|
249
280
|
* A file-system backed cache layer.
|
|
@@ -263,6 +294,7 @@ declare class DiskLayer implements CacheLayer {
|
|
|
263
294
|
private readonly directory;
|
|
264
295
|
private readonly serializer;
|
|
265
296
|
private readonly maxFiles;
|
|
297
|
+
private readonly maxEntryBytes;
|
|
266
298
|
private writeQueue;
|
|
267
299
|
constructor(options: DiskLayerOptions);
|
|
268
300
|
get<T>(key: string): Promise<T | null>;
|
|
@@ -280,12 +312,18 @@ declare class DiskLayer implements CacheLayer {
|
|
|
280
312
|
* Expired entries are skipped and cleaned up during the scan.
|
|
281
313
|
*/
|
|
282
314
|
keys(): Promise<string[]>;
|
|
315
|
+
forEachKey(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
283
316
|
size(): Promise<number>;
|
|
284
317
|
ping(): Promise<boolean>;
|
|
285
318
|
dispose(): Promise<void>;
|
|
286
319
|
private keyToPath;
|
|
287
320
|
private resolveDirectory;
|
|
288
321
|
private normalizeMaxFiles;
|
|
322
|
+
private normalizeMaxEntryBytes;
|
|
323
|
+
private readEntryFile;
|
|
324
|
+
private readHandleWithLimit;
|
|
325
|
+
private scanEntries;
|
|
326
|
+
private deletePathsWithConcurrency;
|
|
289
327
|
private deserializeEntry;
|
|
290
328
|
private safeDelete;
|
|
291
329
|
private enqueueWrite;
|
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-DLstcDMn.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-DLstcDMn.js';
|
|
3
3
|
import Redis from 'ioredis';
|
|
4
4
|
import 'node:events';
|
|
5
5
|
|
|
@@ -47,9 +47,12 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
47
47
|
track(key: string, tags: string[]): Promise<void>;
|
|
48
48
|
remove(key: string): Promise<void>;
|
|
49
49
|
keysForTag(tag: string): Promise<string[]>;
|
|
50
|
+
forEachKeyForTag(tag: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
50
51
|
keysForPrefix(prefix: string): Promise<string[]>;
|
|
52
|
+
forEachKeyForPrefix(prefix: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
51
53
|
tagsForKey(key: string): Promise<string[]>;
|
|
52
54
|
matchPattern(pattern: string): Promise<string[]>;
|
|
55
|
+
forEachKeyMatchingPattern(pattern: string, visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
53
56
|
clear(): Promise<void>;
|
|
54
57
|
private scanIndexKeys;
|
|
55
58
|
private knownKeysKeyFor;
|
|
@@ -58,7 +61,12 @@ declare class RedisTagIndex implements CacheTagIndex {
|
|
|
58
61
|
private tagKeysKey;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
interface CacheStatsHandlerOptions {
|
|
65
|
+
allowPublicAccess?: boolean;
|
|
66
|
+
authorize?: (request: unknown) => boolean | Promise<boolean>;
|
|
67
|
+
unauthorizedStatusCode?: number;
|
|
68
|
+
}
|
|
69
|
+
declare function createCacheStatsHandler(cache: CacheStack, options?: CacheStatsHandlerOptions): (request: unknown, response: {
|
|
62
70
|
setHeader?: (name: string, value: string) => void;
|
|
63
71
|
end: (body: string) => void;
|
|
64
72
|
statusCode?: number;
|
|
@@ -72,11 +80,19 @@ declare function createCachedMethodDecorator<TArgs extends unknown[] = unknown[]
|
|
|
72
80
|
|
|
73
81
|
interface FastifyLike {
|
|
74
82
|
decorate: (name: string, value: unknown) => void;
|
|
75
|
-
get?: (path: string, handler: () => unknown | Promise<unknown>) => void;
|
|
83
|
+
get?: (path: string, handler: (request: unknown, reply: FastifyLikeReply) => unknown | Promise<unknown>) => void;
|
|
84
|
+
}
|
|
85
|
+
interface FastifyLikeReply {
|
|
86
|
+
header?: (name: string, value: string) => unknown;
|
|
87
|
+
send?: (body: unknown) => unknown;
|
|
88
|
+
statusCode?: number;
|
|
76
89
|
}
|
|
77
90
|
interface FastifyLayercachePluginOptions {
|
|
78
91
|
exposeStatsRoute?: boolean;
|
|
79
92
|
statsPath?: string;
|
|
93
|
+
allowPublicStatsRoute?: boolean;
|
|
94
|
+
authorizeStatsRoute?: (request: unknown) => boolean | Promise<boolean>;
|
|
95
|
+
unauthorizedStatusCode?: number;
|
|
80
96
|
}
|
|
81
97
|
declare function createFastifyLayercachePlugin(cache: CacheStack, options?: FastifyLayercachePluginOptions): (fastify: FastifyLike) => Promise<void>;
|
|
82
98
|
|
|
@@ -86,6 +102,8 @@ interface ExpressLikeRequest {
|
|
|
86
102
|
originalUrl?: string;
|
|
87
103
|
path?: string;
|
|
88
104
|
query?: Record<string, unknown>;
|
|
105
|
+
headers?: Headers | Record<string, unknown>;
|
|
106
|
+
get?: (name: string) => string | undefined | null;
|
|
89
107
|
}
|
|
90
108
|
interface ExpressLikeResponse {
|
|
91
109
|
statusCode?: number;
|
|
@@ -104,6 +122,8 @@ interface ExpressCacheMiddlewareOptions extends CacheGetOptions {
|
|
|
104
122
|
* Only cache responses for these HTTP methods. Defaults to `['GET']`.
|
|
105
123
|
*/
|
|
106
124
|
methods?: string[];
|
|
125
|
+
/** Explicitly allow URL-only implicit cache keys. Disabled by default. */
|
|
126
|
+
allowPrivateCaching?: boolean;
|
|
107
127
|
}
|
|
108
128
|
/**
|
|
109
129
|
* Express/Connect-compatible middleware that caches JSON responses.
|
|
@@ -124,6 +144,7 @@ declare function createExpressCacheMiddleware(cache: CacheStack, options?: Expre
|
|
|
124
144
|
|
|
125
145
|
interface GraphqlCacheOptions<TArgs extends unknown[]> extends CacheGetOptions {
|
|
126
146
|
keyResolver?: (...args: TArgs) => string;
|
|
147
|
+
allowImplicitContextCaching?: boolean;
|
|
127
148
|
}
|
|
128
149
|
declare function cacheGraphqlResolver<TArgs extends unknown[], TResult>(cache: CacheStack, prefix: string, resolver: (...args: TArgs) => Promise<TResult>, options?: GraphqlCacheOptions<TArgs>): (...args: TArgs) => Promise<TResult | null>;
|
|
129
150
|
|
|
@@ -159,6 +180,7 @@ interface TrpcCacheMiddlewareContext<TInput = unknown, TResult = unknown> {
|
|
|
159
180
|
}
|
|
160
181
|
interface TrpcCacheMiddlewareOptions<TInput> extends CacheGetOptions {
|
|
161
182
|
keyResolver?: (input: TInput, path?: string, type?: string) => string;
|
|
183
|
+
allowImplicitContextCaching?: boolean;
|
|
162
184
|
}
|
|
163
185
|
declare function createTrpcCacheMiddleware<TInput = unknown, TResult = unknown>(cache: CacheStack, prefix: string, options?: TrpcCacheMiddlewareOptions<TInput>): (context: TrpcCacheMiddlewareContext<TInput, TResult>) => Promise<{
|
|
164
186
|
ok: boolean;
|
|
@@ -215,9 +237,11 @@ declare class RedisLayer implements CacheLayer {
|
|
|
215
237
|
*/
|
|
216
238
|
clear(): Promise<void>;
|
|
217
239
|
keys(): Promise<string[]>;
|
|
240
|
+
forEachKey(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
218
241
|
private scanKeys;
|
|
219
242
|
private withPrefix;
|
|
220
243
|
private deserializeOrDelete;
|
|
244
|
+
private deleteCorruptedKey;
|
|
221
245
|
private rewriteWithPrimarySerializer;
|
|
222
246
|
private primarySerializer;
|
|
223
247
|
private isSerializablePayload;
|
|
@@ -231,6 +255,7 @@ declare class RedisLayer implements CacheLayer {
|
|
|
231
255
|
* Enforces a maximum decompressed size to prevent decompression bomb attacks.
|
|
232
256
|
*/
|
|
233
257
|
private decodePayload;
|
|
258
|
+
private decompressWithLimit;
|
|
234
259
|
}
|
|
235
260
|
|
|
236
261
|
interface DiskLayerOptions {
|
|
@@ -244,6 +269,12 @@ interface DiskLayerOptions {
|
|
|
244
269
|
* Defaults to unlimited.
|
|
245
270
|
*/
|
|
246
271
|
maxFiles?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Maximum size, in bytes, of a single cache file that this layer will read.
|
|
274
|
+
* Oversized entries are treated as corrupted and removed. Defaults to 16 MiB.
|
|
275
|
+
* Set to `false` to disable the limit.
|
|
276
|
+
*/
|
|
277
|
+
maxEntryBytes?: number | false;
|
|
247
278
|
}
|
|
248
279
|
/**
|
|
249
280
|
* A file-system backed cache layer.
|
|
@@ -263,6 +294,7 @@ declare class DiskLayer implements CacheLayer {
|
|
|
263
294
|
private readonly directory;
|
|
264
295
|
private readonly serializer;
|
|
265
296
|
private readonly maxFiles;
|
|
297
|
+
private readonly maxEntryBytes;
|
|
266
298
|
private writeQueue;
|
|
267
299
|
constructor(options: DiskLayerOptions);
|
|
268
300
|
get<T>(key: string): Promise<T | null>;
|
|
@@ -280,12 +312,18 @@ declare class DiskLayer implements CacheLayer {
|
|
|
280
312
|
* Expired entries are skipped and cleaned up during the scan.
|
|
281
313
|
*/
|
|
282
314
|
keys(): Promise<string[]>;
|
|
315
|
+
forEachKey(visitor: (key: string) => void | Promise<void>): Promise<void>;
|
|
283
316
|
size(): Promise<number>;
|
|
284
317
|
ping(): Promise<boolean>;
|
|
285
318
|
dispose(): Promise<void>;
|
|
286
319
|
private keyToPath;
|
|
287
320
|
private resolveDirectory;
|
|
288
321
|
private normalizeMaxFiles;
|
|
322
|
+
private normalizeMaxEntryBytes;
|
|
323
|
+
private readEntryFile;
|
|
324
|
+
private readHandleWithLimit;
|
|
325
|
+
private scanEntries;
|
|
326
|
+
private deletePathsWithConcurrency;
|
|
289
327
|
private deserializeEntry;
|
|
290
328
|
private safeDelete;
|
|
291
329
|
private enqueueWrite;
|