tricache 1.0.2 → 2.0.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.
Files changed (101) hide show
  1. package/README.md +78 -90
  2. package/dashboards/tricache-alerts.yaml +80 -4
  3. package/dashboards/tricache-grafana.json +54 -1
  4. package/dashboards/tricache-inventory.rules.yml +21 -0
  5. package/dist/{cache-service-CWI4jkS7.d.cts → cache-service-BV5T8-20.d.cts} +122 -21
  6. package/dist/cache-service-UZXOQGEY.js +14 -0
  7. package/dist/{cache-service-B108FzER.d.ts → cache-service-tpyrXvlH.d.ts} +122 -21
  8. package/dist/{chunk-UBWLPKTI.js → chunk-EJXG7WO6.js} +152 -32
  9. package/dist/{chunk-H4GFLQ26.js → chunk-KV7KISK2.js} +47 -1
  10. package/dist/{chunk-WYF7NOAT.js → chunk-MB3DMVWN.js} +2111 -543
  11. package/dist/{chunk-OYDU3SMI.js → chunk-RBJRTGFK.js} +5 -0
  12. package/dist/chunk-S5N65I45.js +17 -0
  13. package/dist/cli.cjs +2454 -572
  14. package/dist/cli.js +186 -11
  15. package/dist/dashboard/index.d.cts +2 -2
  16. package/dist/dashboard/index.d.ts +2 -2
  17. package/dist/drizzle/index.cjs +2335 -571
  18. package/dist/drizzle/index.d.cts +2 -2
  19. package/dist/drizzle/index.d.ts +2 -2
  20. package/dist/drizzle/index.js +6 -2
  21. package/dist/edge/index.cjs +145 -43
  22. package/dist/edge/index.d.cts +11 -4
  23. package/dist/edge/index.d.ts +11 -4
  24. package/dist/edge/index.js +118 -43
  25. package/dist/hono/index.cjs +2322 -569
  26. package/dist/hono/index.d.cts +2 -2
  27. package/dist/hono/index.d.ts +2 -2
  28. package/dist/hono/index.js +2 -2
  29. package/dist/{hono-C886ok3X.d.cts → hono-CMv2VdQ6.d.cts} +18 -5
  30. package/dist/{hono-3rDMYVtY.d.ts → hono-Dvq04kX9.d.ts} +18 -5
  31. package/dist/http/index.cjs +2323 -570
  32. package/dist/http/index.d.cts +3 -3
  33. package/dist/http/index.d.ts +3 -3
  34. package/dist/http/index.js +4 -4
  35. package/dist/index.cjs +2554 -620
  36. package/dist/index.d.cts +88 -23
  37. package/dist/index.d.ts +88 -23
  38. package/dist/index.js +873 -16
  39. package/dist/{murmur3-CMGw9PbV.d.cts → murmur3-DF8BFRnu.d.cts} +1 -0
  40. package/dist/{murmur3-CMGw9PbV.d.ts → murmur3-DF8BFRnu.d.ts} +1 -0
  41. package/dist/nestjs/index.cjs +2292 -574
  42. package/dist/nestjs/index.d.cts +19 -5
  43. package/dist/nestjs/index.d.ts +19 -5
  44. package/dist/nestjs/index.js +25 -19
  45. package/dist/next/index.cjs +2306 -571
  46. package/dist/next/index.d.cts +8 -2
  47. package/dist/next/index.d.ts +8 -2
  48. package/dist/next/index.js +36 -9
  49. package/dist/prisma/index.cjs +26 -25
  50. package/dist/prisma/index.d.cts +2 -2
  51. package/dist/prisma/index.d.ts +2 -2
  52. package/dist/prisma/index.js +14 -25
  53. package/dist/serialize-worker.cjs +162 -39
  54. package/dist/serialize-worker.js +9 -7
  55. package/dist/{types-BA4pz1A0.d.cts → types-F8vRWMrE.d.cts} +162 -45
  56. package/dist/{types-BA4pz1A0.d.ts → types-F8vRWMrE.d.ts} +162 -45
  57. package/package.json +21 -2
  58. package/src/adapters/auto-pipeliner.ts +52 -11
  59. package/src/cache-service.ts +1537 -415
  60. package/src/cli.ts +2 -9
  61. package/src/codec.ts +3 -3
  62. package/src/compression.ts +39 -16
  63. package/src/cross-region.ts +1 -1
  64. package/src/disk-tier.ts +283 -43
  65. package/src/drizzle/index.ts +2 -1
  66. package/src/edge/adapters/cloudflare-do.ts +25 -10
  67. package/src/edge/adapters/cloudflare-kv.ts +12 -9
  68. package/src/edge/adapters/upstash.ts +27 -11
  69. package/src/edge/cache.ts +59 -17
  70. package/src/edge/types.ts +15 -5
  71. package/src/encryption.ts +50 -18
  72. package/src/env.d.ts +1 -1
  73. package/src/errors.ts +12 -0
  74. package/src/http/utils.ts +6 -0
  75. package/src/index.ts +6 -0
  76. package/src/latency-watchdog.ts +5 -1
  77. package/src/nestjs/decorators.ts +11 -6
  78. package/src/nestjs/tricache.module.ts +2 -1
  79. package/src/nestjs/tricache.store.ts +21 -9
  80. package/src/nestjs/types.ts +1 -1
  81. package/src/next/cache-handler.ts +24 -4
  82. package/src/next/types.ts +4 -0
  83. package/src/origin-capacity.ts +134 -0
  84. package/src/prisma/index.ts +14 -32
  85. package/src/remote-snapshot.ts +37 -27
  86. package/src/serialize-worker.ts +8 -5
  87. package/src/sigv4-snapshot-adapter.ts +37 -27
  88. package/src/smart-memory-cache.ts +62 -22
  89. package/src/types.ts +92 -35
  90. package/src/utils/config-comparison.ts +29 -0
  91. package/src/utils/lz4-size.ts +74 -0
  92. package/src/utils/namespace-key.ts +48 -0
  93. package/src/utils/query-key.ts +13 -0
  94. package/src/utils/snapshot-transfer.ts +83 -0
  95. package/src/utils/work-limits.ts +73 -0
  96. package/src/utils/write-revision.ts +4 -0
  97. package/src/wasm/bloom-filter-wasm.ts +16 -1
  98. package/src/worker-pool.ts +28 -8
  99. package/src/wtiny-lfu.ts +62 -14
  100. package/dist/cache-service-GYPZFB7O.js +0 -12
  101. package/dist/chunk-VNRDL5RA.js +0 -666
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-CWI4jkS7.cjs';
2
- import { W as WrapOptions } from '../types-BA4pz1A0.cjs';
1
+ import { C as CacheService } from '../cache-service-BV5T8-20.cjs';
2
+ import { W as WrapOptions } from '../types-F8vRWMrE.cjs';
3
3
  import { K as KeyDerivationOptions } from '../utils-Bvzn-rKS.cjs';
4
4
  import 'crypto';
5
5
 
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-B108FzER.js';
2
- import { W as WrapOptions } from '../types-BA4pz1A0.js';
1
+ import { C as CacheService } from '../cache-service-tpyrXvlH.js';
2
+ import { W as WrapOptions } from '../types-F8vRWMrE.js';
3
3
  import { K as KeyDerivationOptions } from '../utils-Bvzn-rKS.js';
4
4
  import 'crypto';
5
5
 
@@ -4,7 +4,7 @@ import {
4
4
  isShareableHttpResponse,
5
5
  matchesETag,
6
6
  shouldSkipCache
7
- } from "../chunk-OYDU3SMI.js";
7
+ } from "../chunk-RBJRTGFK.js";
8
8
 
9
9
  // src/hono/index.ts
10
10
  function readRequestHeader(c, name) {
@@ -149,7 +149,7 @@ function cacheMiddleware(options = {}) {
149
149
  return await next();
150
150
  }
151
151
  if (!resolvedCache) {
152
- const { CacheService } = await import("../cache-service-GYPZFB7O.js");
152
+ const { CacheService } = await import("../cache-service-UZXOQGEY.js");
153
153
  resolvedCache = CacheService.create();
154
154
  }
155
155
  const activeCache = resolvedCache;
@@ -1,4 +1,4 @@
1
- import { I as ICacheTracer, a as InvalidateTagOptions } from './types-BA4pz1A0.cjs';
1
+ import { I as ICacheTracer, a as InvalidateTagOptions } from './types-F8vRWMrE.cjs';
2
2
 
3
3
  /**
4
4
  * Pluggable asynchronous key-value storage adapter for Edge runtimes (L2 tier).
@@ -16,11 +16,15 @@ interface IEdgeRemoteStorage {
16
16
  mset?(entries: Record<string, string>, ttlSeconds?: number): Promise<void>;
17
17
  /** Optional clear by prefix or all keys. */
18
18
  clear?(prefix?: string): Promise<void>;
19
- /** Optional atomic or monotonic tag version increment for generational tag invalidation. */
19
+ /** Enumerate complete keys under a literal prefix in bounded pages. Required for remote wildcard tags. */
20
+ scanKeys?(prefix: string): AsyncIterable<string>;
21
+ /** Counter semantics; Workers KV is eventually consistent, not an atomic authority. */
22
+ readonly tagConsistency?: 'atomic' | 'eventual';
23
+ /** Optional atomic or monotonic tag increment. The service supplies the complete typed storage key; adapters must use it unchanged. */
20
24
  incrementTagVersion?(tag: string): Promise<number>;
21
- /** Optional tag version retrieval. */
25
+ /** Optional tag version retrieval by complete typed storage key. */
22
26
  getTagVersion?(tag: string): Promise<number>;
23
- /** Optional batch tag version retrieval. */
27
+ /** Optional batch tag retrieval; result keys must match the complete supplied storage keys. */
24
28
  batchGetTagVersions?(tags: string[]): Promise<Record<string, number>>;
25
29
  }
26
30
  /**
@@ -67,7 +71,7 @@ interface EdgeCacheOptions {
67
71
  prevKeyBase64?: string;
68
72
  mode?: 'aes-256-gcm' | 'aes-128-gcm';
69
73
  };
70
- /** Multi-tenant key namespace prefix. */
74
+ /** Namespace encoded into a v3 storage keyspace with disjoint data/tag domains. Upgrades start cold; coordinate writers. Use a separate namespace from Node, whose value format differs. */
71
75
  namespace?: string;
72
76
  /** OpenTelemetry-compatible tracer for distributed tracing. */
73
77
  tracer?: ICacheTracer;
@@ -105,6 +109,8 @@ interface UpstashRedisOptions {
105
109
  token: string;
106
110
  /** Optional custom fetch implementation (defaults to globalThis.fetch). */
107
111
  fetch?: typeof globalThis.fetch;
112
+ /** Allow an explicit unscoped clear() to execute FLUSHDB. Default: false. */
113
+ dangerouslyFlushDatabase?: boolean;
108
114
  }
109
115
  /**
110
116
  * Minimal interface representing Cloudflare Workers KVNamespace binding.
@@ -146,6 +152,7 @@ interface CloudflareDOStorage {
146
152
  list?<T = unknown>(options?: {
147
153
  prefix?: string;
148
154
  limit?: number;
155
+ startAfter?: string;
149
156
  }): Promise<Map<string, T>>;
150
157
  }
151
158
  /**
@@ -204,6 +211,8 @@ interface EdgeExportSnapshotOptions {
204
211
  */
205
212
  interface EdgeSnapshotPayload {
206
213
  version: number;
214
+ /** Encoded storage namespace identity, not the raw namespace option. */
215
+ namespace: string;
207
216
  writtenAt: number;
208
217
  entries: Array<{
209
218
  key: string;
@@ -232,6 +241,9 @@ declare class EdgeCacheService {
232
241
  private readonly maxBytes;
233
242
  private readonly defaultTtl;
234
243
  private readonly namespace;
244
+ private readonly namespacePrefix;
245
+ private readonly dataPrefix;
246
+ private readonly tagVersionPrefix;
235
247
  private readonly remoteStorage;
236
248
  private readonly enc;
237
249
  private readonly tracer;
@@ -253,6 +265,7 @@ declare class EdgeCacheService {
253
265
  */
254
266
  get bloom(): IEdgeBloomFilter | null;
255
267
  private nk;
268
+ private tagVersionKey;
256
269
  private _estimateBytes;
257
270
  private fence;
258
271
  private mutate;
@@ -1,4 +1,4 @@
1
- import { I as ICacheTracer, a as InvalidateTagOptions } from './types-BA4pz1A0.js';
1
+ import { I as ICacheTracer, a as InvalidateTagOptions } from './types-F8vRWMrE.js';
2
2
 
3
3
  /**
4
4
  * Pluggable asynchronous key-value storage adapter for Edge runtimes (L2 tier).
@@ -16,11 +16,15 @@ interface IEdgeRemoteStorage {
16
16
  mset?(entries: Record<string, string>, ttlSeconds?: number): Promise<void>;
17
17
  /** Optional clear by prefix or all keys. */
18
18
  clear?(prefix?: string): Promise<void>;
19
- /** Optional atomic or monotonic tag version increment for generational tag invalidation. */
19
+ /** Enumerate complete keys under a literal prefix in bounded pages. Required for remote wildcard tags. */
20
+ scanKeys?(prefix: string): AsyncIterable<string>;
21
+ /** Counter semantics; Workers KV is eventually consistent, not an atomic authority. */
22
+ readonly tagConsistency?: 'atomic' | 'eventual';
23
+ /** Optional atomic or monotonic tag increment. The service supplies the complete typed storage key; adapters must use it unchanged. */
20
24
  incrementTagVersion?(tag: string): Promise<number>;
21
- /** Optional tag version retrieval. */
25
+ /** Optional tag version retrieval by complete typed storage key. */
22
26
  getTagVersion?(tag: string): Promise<number>;
23
- /** Optional batch tag version retrieval. */
27
+ /** Optional batch tag retrieval; result keys must match the complete supplied storage keys. */
24
28
  batchGetTagVersions?(tags: string[]): Promise<Record<string, number>>;
25
29
  }
26
30
  /**
@@ -67,7 +71,7 @@ interface EdgeCacheOptions {
67
71
  prevKeyBase64?: string;
68
72
  mode?: 'aes-256-gcm' | 'aes-128-gcm';
69
73
  };
70
- /** Multi-tenant key namespace prefix. */
74
+ /** Namespace encoded into a v3 storage keyspace with disjoint data/tag domains. Upgrades start cold; coordinate writers. Use a separate namespace from Node, whose value format differs. */
71
75
  namespace?: string;
72
76
  /** OpenTelemetry-compatible tracer for distributed tracing. */
73
77
  tracer?: ICacheTracer;
@@ -105,6 +109,8 @@ interface UpstashRedisOptions {
105
109
  token: string;
106
110
  /** Optional custom fetch implementation (defaults to globalThis.fetch). */
107
111
  fetch?: typeof globalThis.fetch;
112
+ /** Allow an explicit unscoped clear() to execute FLUSHDB. Default: false. */
113
+ dangerouslyFlushDatabase?: boolean;
108
114
  }
109
115
  /**
110
116
  * Minimal interface representing Cloudflare Workers KVNamespace binding.
@@ -146,6 +152,7 @@ interface CloudflareDOStorage {
146
152
  list?<T = unknown>(options?: {
147
153
  prefix?: string;
148
154
  limit?: number;
155
+ startAfter?: string;
149
156
  }): Promise<Map<string, T>>;
150
157
  }
151
158
  /**
@@ -204,6 +211,8 @@ interface EdgeExportSnapshotOptions {
204
211
  */
205
212
  interface EdgeSnapshotPayload {
206
213
  version: number;
214
+ /** Encoded storage namespace identity, not the raw namespace option. */
215
+ namespace: string;
207
216
  writtenAt: number;
208
217
  entries: Array<{
209
218
  key: string;
@@ -232,6 +241,9 @@ declare class EdgeCacheService {
232
241
  private readonly maxBytes;
233
242
  private readonly defaultTtl;
234
243
  private readonly namespace;
244
+ private readonly namespacePrefix;
245
+ private readonly dataPrefix;
246
+ private readonly tagVersionPrefix;
235
247
  private readonly remoteStorage;
236
248
  private readonly enc;
237
249
  private readonly tracer;
@@ -253,6 +265,7 @@ declare class EdgeCacheService {
253
265
  */
254
266
  get bloom(): IEdgeBloomFilter | null;
255
267
  private nk;
268
+ private tagVersionKey;
256
269
  private _estimateBytes;
257
270
  private fence;
258
271
  private mutate;