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
package/dist/cli.js CHANGED
@@ -4,13 +4,194 @@ import {
4
4
  findActiveSockets,
5
5
  renderTopDashboard,
6
6
  resolveIpcSocketPath
7
- } from "./chunk-WYF7NOAT.js";
8
- import "./chunk-UBWLPKTI.js";
9
- import "./chunk-H4GFLQ26.js";
7
+ } from "./chunk-MB3DMVWN.js";
8
+ import "./chunk-EJXG7WO6.js";
9
+ import "./chunk-KV7KISK2.js";
10
10
 
11
11
  // src/cli.ts
12
- import { readFileSync } from "fs";
13
12
  import { parseArgs } from "util";
13
+
14
+ // package.json
15
+ var package_default = {
16
+ name: "tricache",
17
+ version: "2.0.0",
18
+ description: "Node.js caching with bounded memory, Redis/Valkey sharing, tag invalidation, stale-while-revalidate, per-process request coalescing, framework adapters, and optional local disk spill.",
19
+ keywords: [
20
+ "cache",
21
+ "redis",
22
+ "valkey",
23
+ "lru",
24
+ "lfu",
25
+ "bloom-filter",
26
+ "count-min-sketch",
27
+ "swr",
28
+ "stale-while-revalidate",
29
+ "msgpack",
30
+ "aes-256-gcm",
31
+ "envelope-encryption",
32
+ "nextjs",
33
+ "express",
34
+ "fastify",
35
+ "hono",
36
+ "edge",
37
+ "cli",
38
+ "nodejs"
39
+ ],
40
+ license: "MIT",
41
+ author: "Kareem (https://github.com/Kareem411)",
42
+ repository: {
43
+ type: "git",
44
+ url: "git+https://github.com/Kareem411/TriCache.git"
45
+ },
46
+ homepage: "https://github.com/Kareem411/TriCache#readme",
47
+ packageManager: "pnpm@11.22.0",
48
+ sideEffects: false,
49
+ type: "module",
50
+ main: "./dist/index.js",
51
+ module: "./dist/index.js",
52
+ types: "./dist/index.d.ts",
53
+ bin: {
54
+ tricache: "./bin/tricache.js"
55
+ },
56
+ exports: {
57
+ ".": {
58
+ import: { types: "./dist/index.d.ts", default: "./dist/index.js" },
59
+ require: { types: "./dist/index.d.cts", default: "./dist/index.cjs" }
60
+ },
61
+ "./next": {
62
+ import: { types: "./dist/next/index.d.ts", default: "./dist/next/index.js" },
63
+ require: { types: "./dist/next/index.d.cts", default: "./dist/next/index.cjs" }
64
+ },
65
+ "./nestjs": {
66
+ import: { types: "./dist/nestjs/index.d.ts", default: "./dist/nestjs/index.js" },
67
+ require: { types: "./dist/nestjs/index.d.cts", default: "./dist/nestjs/index.cjs" }
68
+ },
69
+ "./prisma": {
70
+ import: { types: "./dist/prisma/index.d.ts", default: "./dist/prisma/index.js" },
71
+ require: { types: "./dist/prisma/index.d.cts", default: "./dist/prisma/index.cjs" }
72
+ },
73
+ "./drizzle": {
74
+ import: { types: "./dist/drizzle/index.d.ts", default: "./dist/drizzle/index.js" },
75
+ require: { types: "./dist/drizzle/index.d.cts", default: "./dist/drizzle/index.cjs" }
76
+ },
77
+ "./http": {
78
+ import: { types: "./dist/http/index.d.ts", default: "./dist/http/index.js" },
79
+ require: { types: "./dist/http/index.d.cts", default: "./dist/http/index.cjs" }
80
+ },
81
+ "./hono": {
82
+ import: { types: "./dist/hono/index.d.ts", default: "./dist/hono/index.js" },
83
+ require: { types: "./dist/hono/index.d.cts", default: "./dist/hono/index.cjs" }
84
+ },
85
+ "./dashboard": {
86
+ import: { types: "./dist/dashboard/index.d.ts", default: "./dist/dashboard/index.js" },
87
+ require: { types: "./dist/dashboard/index.d.cts", default: "./dist/dashboard/index.cjs" }
88
+ },
89
+ "./edge": {
90
+ "edge-light": { types: "./dist/edge/index.d.ts", default: "./dist/edge/index.js" },
91
+ workerd: { types: "./dist/edge/index.d.ts", default: "./dist/edge/index.js" },
92
+ import: { types: "./dist/edge/index.d.ts", default: "./dist/edge/index.js" },
93
+ require: { types: "./dist/edge/index.d.cts", default: "./dist/edge/index.cjs" },
94
+ default: "./dist/edge/index.js"
95
+ }
96
+ },
97
+ files: [
98
+ "bin",
99
+ "dashboards",
100
+ "dist",
101
+ "src",
102
+ "README.md",
103
+ "LICENSE"
104
+ ],
105
+ scripts: {
106
+ build: "tsup src/index.ts src/cli.ts src/serialize-worker.ts src/next/index.ts src/nestjs/index.ts src/prisma/index.ts src/drizzle/index.ts src/http/index.ts src/hono/index.ts src/dashboard/index.ts src/edge/index.ts --format esm,cjs --dts --clean",
107
+ dev: "tsup src/index.ts src/serialize-worker.ts --format esm,cjs --dts --watch",
108
+ typecheck: "tsc --noEmit",
109
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json",
110
+ "typecheck:all": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
111
+ lint: "oxlint src tests scripts",
112
+ test: "vitest run",
113
+ "test:integration": "vitest run --config vitest.integration.config.ts",
114
+ "test:shutdown-docker": "node scripts/run-shutdown-probes.mjs",
115
+ "test:storage-docker": "node scripts/run-storage-permission-probes.mjs",
116
+ "test:recovery-docker": "node scripts/run-redis-recovery-probes.mjs",
117
+ "test:rollout-docker": "node scripts/run-redis-recovery-probes.mjs --rollout",
118
+ "test:watch": "vitest",
119
+ "check:package": "node scripts/check-package.mjs",
120
+ "check:release-version": "node scripts/check-release-version.mjs",
121
+ "check:production-start": "node scripts/check-production-start.mjs",
122
+ "check:rehearsal-runner": "node --test tests/rehearsal-runner.test.mjs tests/m3-protocol.test.mjs",
123
+ "check:m3-rehearsal": "node --test tests/m3-rehearsal.test.mjs tests/service-telemetry.test.mjs tests/production-service.test.mjs",
124
+ "check:spill-crash": "node scripts/check-spill-crash.mjs",
125
+ "check:edge-provider": "node scripts/check-edge-provider.mjs",
126
+ bench: "node --expose-gc --max-old-space-size=8192 --import tsx/esm bench/benchmark.ts",
127
+ "bench:roi": "tsx bench/cloud-roi-simulation.ts",
128
+ "bench:compression": "tsx bench/compression.bench.ts",
129
+ "bench:compare": "tsx bench/compare/runner.ts",
130
+ "bench:compare:smoke": "tsx bench/compare/runner.ts --quick",
131
+ "bench:tag-refresh": "node bench/tag-refresh/run.mjs",
132
+ "bench:public-trace": "tsx bench/public-trace/run-baseline.ts",
133
+ "bench:public-trace:l1": "node --import tsx/esm bench/public-trace/run-l1.ts",
134
+ "bench:public-trace:admission": "node --import tsx/esm bench/public-trace/run-admission-probe.ts",
135
+ "bench:public-trace:calibrate-admission": "node --import tsx/esm bench/public-trace/run-admission-calibration.ts",
136
+ "bench:public-trace:entry-policy": "node --import tsx/esm bench/public-trace/run-entry-policy.ts",
137
+ "bench:outage": "node bench/compare/outage-runner.ts",
138
+ "lint:bench": "oxlint bench/compare bench/tag-refresh bench/public-trace",
139
+ "docs:dev": "vitepress dev docs",
140
+ "docs:build": "vitepress build docs",
141
+ "docs:preview": "vitepress preview docs",
142
+ "docs:start": "vitepress preview docs"
143
+ },
144
+ peerDependencies: {
145
+ "@nestjs/common": "^10.0.0 || ^11.0.0 || ^12.0.0",
146
+ "@nestjs/core": "^10.0.0 || ^11.0.0 || ^12.0.0",
147
+ hono: ">=3.0.0 <5.0.0"
148
+ },
149
+ peerDependenciesMeta: {
150
+ "@nestjs/common": {
151
+ optional: true
152
+ },
153
+ "@nestjs/core": {
154
+ optional: true
155
+ },
156
+ hono: {
157
+ optional: true
158
+ }
159
+ },
160
+ dependencies: {
161
+ ioredis: "6.0.0",
162
+ lz4js: "^0.2.0",
163
+ msgpackr: "2.1.2",
164
+ "zstd-codec": "^0.1.5"
165
+ },
166
+ devDependencies: {
167
+ "@nestjs/cache-manager": "12.0.5",
168
+ "@nestjs/common": "^12.5.0",
169
+ "@nestjs/core": "^12.5.0",
170
+ "@nestjs/platform-express": "^12.5.0",
171
+ "@types/node": "^26.6.2",
172
+ "@opentelemetry/api": "^1.10.0",
173
+ "cache-manager": "7.2.9",
174
+ hono: "^4.13.16",
175
+ keyv: "5.6.0",
176
+ "markdown-it-mathjax3": "^4.3.2",
177
+ next: "16.4.6",
178
+ oxlint: "^1.85.0",
179
+ redis: "^6.2.1",
180
+ "reflect-metadata": "^0.2.2",
181
+ rxjs: "^7.8.2",
182
+ tsup: "^8.5.1",
183
+ tsx: "^4.23.15",
184
+ typescript: "^6.0.3",
185
+ vite: "^8.3.5",
186
+ vitepress: "2.0.0-alpha.20",
187
+ vitest: "^4.1.12"
188
+ },
189
+ engines: {
190
+ node: ">=20.10.0"
191
+ }
192
+ };
193
+
194
+ // src/cli.ts
14
195
  import { Redis } from "ioredis";
15
196
  async function runCli(args = process.argv.slice(2)) {
16
197
  const options = {
@@ -48,13 +229,7 @@ async function runCli(args = process.argv.slice(2)) {
48
229
  return;
49
230
  }
50
231
  if (values.version || command === "version") {
51
- let version = "1.0.2";
52
- try {
53
- const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
54
- if (pkg?.version) version = pkg.version;
55
- } catch {
56
- }
57
- console.log(`tricache v${version}`);
232
+ console.log(`tricache v${package_default.version}`);
58
233
  return;
59
234
  }
60
235
  if (command === "top") {
@@ -1,6 +1,6 @@
1
1
  import http, { IncomingMessage, ServerResponse } from 'node:http';
2
- import { C as CacheService } from '../cache-service-CWI4jkS7.cjs';
3
- import '../types-BA4pz1A0.cjs';
2
+ import { C as CacheService } from '../cache-service-BV5T8-20.cjs';
3
+ import '../types-F8vRWMrE.cjs';
4
4
  import 'crypto';
5
5
 
6
6
  interface DashboardPeerInstance {
@@ -1,6 +1,6 @@
1
1
  import http, { IncomingMessage, ServerResponse } from 'node:http';
2
- import { C as CacheService } from '../cache-service-B108FzER.js';
3
- import '../types-BA4pz1A0.js';
2
+ import { C as CacheService } from '../cache-service-tpyrXvlH.js';
3
+ import '../types-F8vRWMrE.js';
4
4
  import 'crypto';
5
5
 
6
6
  interface DashboardPeerInstance {