tricache 1.0.0 → 1.0.1
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 +1 -1
- package/dist/{cache-service-pJ-nFcVj.d.ts → cache-service-CREOp7MM.d.ts} +29 -1
- package/dist/{cache-service-26GCO3UU.js → cache-service-MG7PN6MX.js} +1 -1
- package/dist/{chunk-VXFTFZ5N.js → chunk-3I5L7K6I.js} +17 -0
- package/dist/{chunk-7SZSQS55.js → chunk-JYQFQJNJ.js} +533 -295
- package/dist/cli.cjs +534 -296
- package/dist/cli.js +2 -2
- package/dist/dashboard/index.d.ts +2 -2
- package/dist/drizzle/index.cjs +533 -295
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +1 -1
- package/dist/edge/index.cjs +55 -32
- package/dist/edge/index.d.ts +3 -3
- package/dist/edge/index.js +55 -32
- package/dist/hono/index.cjs +533 -295
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +1 -1
- package/dist/{hono-DuNvciyq.d.ts → hono-DSV2ve66.d.ts} +8 -1
- package/dist/http/index.cjs +585 -316
- package/dist/http/index.d.ts +3 -3
- package/dist/http/index.js +55 -24
- package/dist/index.cjs +550 -295
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -2
- package/dist/nestjs/index.cjs +533 -295
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/nestjs/index.js +2 -2
- package/dist/next/index.cjs +535 -303
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +3 -9
- package/dist/prisma/index.d.ts +2 -2
- package/dist/{types-5HXqBfAf.d.ts → types-Dyip5wAl.d.ts} +2 -0
- package/package.json +1 -1
- package/src/adapters/node-redis.ts +19 -0
- package/src/cache-service.ts +599 -320
- package/src/cli.ts +1 -1
- package/src/edge/cache.ts +60 -35
- package/src/http/express.ts +55 -16
- package/src/http/fastify.ts +3 -7
- package/src/next/cache-handler.ts +1 -4
- package/src/next/isr-handler.ts +1 -4
- package/src/smart-memory-cache.ts +3 -2
- package/src/types.ts +2 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://kareem411.github.io/TriCache/)
|
|
5
5
|
[](https://www.npmjs.com/package/tricache)
|
|
6
6
|
[](https://www.npmjs.com/package/tricache)
|
|
7
|
-
[](tests)
|
|
8
8
|
[](src)
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
[](https://nodejs.org)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CacheOptions, b as CacheMetrics, c as CacheHealthStatus, d as CachePresetType, e as CrossRegionInvalidationEvent, f as CachePriority, W as WrapOptions, a as InvalidateTagOptions, g as CachePingResult, D as DiskBackpressureStats, L as LockOptions, E as EncryptionMode, h as WTinyLfuStats } from './types-
|
|
1
|
+
import { C as CacheOptions, b as CacheMetrics, c as CacheHealthStatus, d as CachePresetType, e as CrossRegionInvalidationEvent, f as CachePriority, W as WrapOptions, a as InvalidateTagOptions, g as CachePingResult, D as DiskBackpressureStats, L as LockOptions, E as EncryptionMode, h as WTinyLfuStats } from './types-Dyip5wAl.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TierLatencyWatchdog — Graduated, self-healing tier latency watchdog.
|
|
@@ -237,6 +237,8 @@ declare class CacheService {
|
|
|
237
237
|
private readonly _l1Counters;
|
|
238
238
|
/** tag → Set of namespaced cache keys; maintained in-process for O(1) invalidateTag() */
|
|
239
239
|
private readonly tagIndex;
|
|
240
|
+
/** Reverse index of namespaced key → { tags, expiresAt } for bounded cleanup on eviction/delete */
|
|
241
|
+
private readonly keyTags;
|
|
240
242
|
/** tag → { version, lastSyncedAt } for generational tag invalidation (bounded to 10,000 entries) */
|
|
241
243
|
private readonly tagVersions;
|
|
242
244
|
/**
|
|
@@ -244,6 +246,9 @@ declare class CacheService {
|
|
|
244
246
|
* When an exact-key delete matches a registered pattern, all dependents are cascaded.
|
|
245
247
|
*/
|
|
246
248
|
private readonly dependencyIndex;
|
|
249
|
+
/** Reverse index of namespaced dependent key → source glob patterns */
|
|
250
|
+
private readonly keyDependencies;
|
|
251
|
+
private readonly _cgroupMemoryLimit;
|
|
247
252
|
private redis;
|
|
248
253
|
private redisConnecting;
|
|
249
254
|
private readonly cb;
|
|
@@ -282,6 +287,12 @@ declare class CacheService {
|
|
|
282
287
|
private _assertActive;
|
|
283
288
|
private _bumpKeyMutation;
|
|
284
289
|
private _getKeyMutationEpoch;
|
|
290
|
+
private _removeKeyTags;
|
|
291
|
+
private _removeKeyDependencies;
|
|
292
|
+
private _handleL1Eviction;
|
|
293
|
+
private _removePrefixFromIndices;
|
|
294
|
+
private _sweepExpiredMetadata;
|
|
295
|
+
private _runOomCheck;
|
|
285
296
|
private _ipcServer?;
|
|
286
297
|
/** Timestamp (Date.now()) when the backplane subscriber last lost its connection. */
|
|
287
298
|
private _subDisconnectedAt;
|
|
@@ -390,6 +401,10 @@ declare class CacheService {
|
|
|
390
401
|
*/
|
|
391
402
|
receiveCrossRegionInvalidation(event: CrossRegionInvalidationEvent): Promise<boolean>;
|
|
392
403
|
private _setLocalTagVersion;
|
|
404
|
+
private _isGenerationalEntryStale;
|
|
405
|
+
private _deleteRedisKeys;
|
|
406
|
+
private _parseGenerationalRedisHash;
|
|
407
|
+
private _readRedisEntry;
|
|
393
408
|
private _getTagVersion;
|
|
394
409
|
private _deleteIfStale;
|
|
395
410
|
/**
|
|
@@ -621,6 +636,7 @@ declare class CacheService {
|
|
|
621
636
|
* if (fresh !== null) return fresh; // serve from L1, no network hop
|
|
622
637
|
*/
|
|
623
638
|
getIfFresh<T = unknown>(cacheKey: string): T | null;
|
|
639
|
+
private _prepareReadValue;
|
|
624
640
|
/**
|
|
625
641
|
* Pure read across cache tiers (L1 RAM → L1.5 Disk → L2 Redis) without invoking a fetcher.
|
|
626
642
|
* Returns the cached value if found and valid, or `null` if absent / expired.
|
|
@@ -698,6 +714,18 @@ declare class CacheService {
|
|
|
698
714
|
* Scans local in-memory indices (tagIndex, tagVersions, L1 entries) and Redis (if connected).
|
|
699
715
|
*/
|
|
700
716
|
private _resolveMatchingTags;
|
|
717
|
+
private _publishTagInvalidation;
|
|
718
|
+
private _removeTagMembersLocal;
|
|
719
|
+
/**
|
|
720
|
+
* Executes invalidation for a single already-resolved concrete tag without
|
|
721
|
+
* wildcard/cascade re-resolution, avoiding mutual recursion with invalidateTags().
|
|
722
|
+
*/
|
|
723
|
+
private _invalidateConcreteTag;
|
|
724
|
+
/**
|
|
725
|
+
* Executes invalidation for an array of already-resolved concrete tags
|
|
726
|
+
* without re-entering wildcard/cascade resolution or invalidateTag().
|
|
727
|
+
*/
|
|
728
|
+
private _invalidateConcreteTags;
|
|
701
729
|
/**
|
|
702
730
|
* Invalidate all keys associated with a tag, wildcard glob pattern, or hierarchical namespace.
|
|
703
731
|
* Deletes from L1, disk, and Redis (both the keyed values and the tag metadata).
|
|
@@ -407,6 +407,14 @@ var NodeRedisPipelineAdapter = class {
|
|
|
407
407
|
}
|
|
408
408
|
return this;
|
|
409
409
|
}
|
|
410
|
+
hgetall(key) {
|
|
411
|
+
if (typeof this.multiInstance.hGetAll === "function") {
|
|
412
|
+
this.multiInstance.hGetAll(key);
|
|
413
|
+
} else {
|
|
414
|
+
this.multiInstance.hgetall(key);
|
|
415
|
+
}
|
|
416
|
+
return this;
|
|
417
|
+
}
|
|
410
418
|
async exec() {
|
|
411
419
|
const raw = await this.multiInstance.exec();
|
|
412
420
|
if (!raw) return null;
|
|
@@ -548,6 +556,15 @@ var NodeRedisAdapter = class _NodeRedisAdapter {
|
|
|
548
556
|
}
|
|
549
557
|
return void 0;
|
|
550
558
|
}
|
|
559
|
+
async hgetall(key) {
|
|
560
|
+
if (typeof this.client.hGetAll === "function") {
|
|
561
|
+
return await this.client.hGetAll(key) ?? {};
|
|
562
|
+
}
|
|
563
|
+
if (typeof this.client.hgetall === "function") {
|
|
564
|
+
return await this.client.hgetall(key) ?? {};
|
|
565
|
+
}
|
|
566
|
+
return {};
|
|
567
|
+
}
|
|
551
568
|
async publish(channel, message) {
|
|
552
569
|
return await this.client.publish(channel, message);
|
|
553
570
|
}
|