tricache 0.7.0 → 0.8.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 (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +144 -1428
  3. package/bin/tricache.js +8 -8
  4. package/dashboards/tricache-alerts.yaml +54 -0
  5. package/dashboards/tricache-grafana.json +548 -0
  6. package/dist/cache-service-5MZXFIGK.js +12 -0
  7. package/dist/cache-service-CyLdpo77.d.ts +871 -0
  8. package/dist/{chunk-3XQUQBOZ.js → chunk-6PQ5MOWR.js} +2950 -523
  9. package/dist/chunk-7RV5ZVBB.js +1023 -0
  10. package/dist/{chunk-PFB5FMEY.js → chunk-LJ5QJB5O.js} +116 -20
  11. package/dist/chunk-QNU7B43J.js +687 -0
  12. package/dist/chunk-UGD4VEPD.js +138 -0
  13. package/dist/chunk-XZL45ABR.js +108 -0
  14. package/dist/chunk-ZTSWCFYO.js +135 -0
  15. package/dist/cli.cjs +2894 -518
  16. package/dist/cli.d.ts +1 -0
  17. package/dist/cli.js +103 -5
  18. package/dist/dashboard/index.cjs +1065 -0
  19. package/dist/dashboard/index.d.ts +183 -0
  20. package/dist/dashboard/index.js +22 -0
  21. package/dist/drizzle/index.cjs +2648 -508
  22. package/dist/drizzle/index.d.ts +3 -1
  23. package/dist/drizzle/index.js +1 -1
  24. package/dist/edge/index.cjs +1498 -0
  25. package/dist/edge/index.d.ts +127 -0
  26. package/dist/edge/index.js +1109 -0
  27. package/dist/hono-DQRS1Xd7.d.ts +370 -0
  28. package/dist/http/index.cjs +3038 -589
  29. package/dist/http/index.d.ts +109 -23
  30. package/dist/http/index.js +238 -62
  31. package/dist/index.cjs +6962 -2487
  32. package/dist/index.d.ts +547 -30
  33. package/dist/index.js +104 -5
  34. package/dist/murmur3-CMGw9PbV.d.ts +98 -0
  35. package/dist/nestjs/index.cjs +2586 -498
  36. package/dist/nestjs/index.d.ts +3 -1
  37. package/dist/nestjs/index.js +6 -3
  38. package/dist/next/index.cjs +2633 -519
  39. package/dist/next/index.d.ts +13 -7
  40. package/dist/next/index.js +45 -18
  41. package/dist/prisma/index.cjs +2 -1
  42. package/dist/prisma/index.d.ts +3 -1
  43. package/dist/prisma/index.js +2 -1
  44. package/dist/serialize-worker.cjs +31 -19
  45. package/dist/serialize-worker.js +1 -1
  46. package/dist/{cache-service-BblHuF3i.d.ts → types-B6krw64X.d.ts} +605 -646
  47. package/package.json +37 -7
  48. package/src/adapters/auto-pipeliner.ts +206 -0
  49. package/src/adapters/node-redis.ts +370 -0
  50. package/src/cache-service.ts +4231 -3226
  51. package/src/cli.ts +261 -143
  52. package/src/codec.ts +72 -0
  53. package/src/compression.ts +56 -63
  54. package/src/cross-region.ts +245 -0
  55. package/src/dashboard/handler.ts +392 -0
  56. package/src/dashboard/html.ts +594 -0
  57. package/src/dashboard/index.ts +195 -0
  58. package/src/dashboard/types.ts +96 -0
  59. package/src/disk-tier.ts +1223 -821
  60. package/src/drizzle/index.ts +86 -86
  61. package/src/edge/adapters/cloudflare-do.ts +130 -0
  62. package/src/edge/adapters/cloudflare-kv.ts +115 -0
  63. package/src/edge/adapters/upstash.ts +143 -0
  64. package/src/edge/cache.ts +797 -0
  65. package/src/edge/crypto.ts +182 -0
  66. package/src/edge/hono.ts +203 -0
  67. package/src/edge/index.ts +37 -0
  68. package/src/edge/types.ts +230 -0
  69. package/src/edge/utils/base64.ts +63 -0
  70. package/src/edge/utils/murmur3.ts +179 -0
  71. package/src/encryption.ts +635 -493
  72. package/src/http/express.ts +195 -0
  73. package/src/http/fastify.ts +260 -0
  74. package/src/http/index.ts +46 -223
  75. package/src/http/utils.ts +92 -0
  76. package/src/index.ts +149 -47
  77. package/src/ipc-telemetry.ts +481 -0
  78. package/src/latency-watchdog.ts +282 -0
  79. package/src/nestjs/decorators.ts +161 -161
  80. package/src/nestjs/index.ts +23 -23
  81. package/src/nestjs/tricache.module.ts +104 -104
  82. package/src/nestjs/tricache.store.ts +97 -97
  83. package/src/nestjs/types.ts +79 -79
  84. package/src/next/cache-handler.ts +271 -244
  85. package/src/next/index.ts +37 -37
  86. package/src/next/isr-handler.ts +105 -105
  87. package/src/next/types.ts +130 -130
  88. package/src/prisma/index.ts +154 -151
  89. package/src/remote-snapshot.ts +153 -0
  90. package/src/serialize-worker.ts +120 -120
  91. package/src/sigv4-snapshot-adapter.ts +260 -0
  92. package/src/smart-memory-cache.ts +1109 -1024
  93. package/src/types.ts +1199 -902
  94. package/src/utils/cgroup.ts +100 -0
  95. package/src/utils/tracing.ts +54 -0
  96. package/src/wasm/bloom-filter-wasm.ts +109 -102
  97. package/src/worker-pool.ts +299 -299
  98. package/src/wtiny-lfu.ts +624 -0
  99. package/dist/cache-service-AJASH5FX.js +0 -7
  100. package/dist/chunk-UBSR5UYA.js +0 -0
package/dist/cli.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * TriCache CLI — Developer & Troubleshooting Inspector
3
3
  *
4
4
  * Usage:
5
+ * npx tricache top [--socket <path>] [--pid <pid>] [--interval <ms>] [--once]
5
6
  * npx tricache inspect [--redis redis://localhost:6379] [--namespace <ns>]
6
7
  * npx tricache ping [--redis redis://localhost:6379]
7
8
  * npx tricache clear [--redis redis://localhost:6379] [--namespace <ns>] [--prefix <prefix>]
package/dist/cli.js CHANGED
@@ -1,7 +1,12 @@
1
1
  import {
2
- CacheService
3
- } from "./chunk-3XQUQBOZ.js";
4
- import "./chunk-PFB5FMEY.js";
2
+ CacheService,
3
+ IpcTelemetryClient,
4
+ findActiveSockets,
5
+ renderTopDashboard,
6
+ resolveIpcSocketPath
7
+ } from "./chunk-6PQ5MOWR.js";
8
+ import "./chunk-LJ5QJB5O.js";
9
+ import "./chunk-XZL45ABR.js";
5
10
 
6
11
  // src/cli.ts
7
12
  import { parseArgs } from "util";
@@ -12,6 +17,11 @@ async function runCli(args = process.argv.slice(2)) {
12
17
  namespace: { type: "string", short: "n" },
13
18
  prefix: { type: "string" },
14
19
  disk: { type: "string", short: "d" },
20
+ pid: { type: "string" },
21
+ socket: { type: "string", short: "s" },
22
+ interval: { type: "string", short: "i" },
23
+ once: { type: "boolean" },
24
+ json: { type: "boolean" },
15
25
  help: { type: "boolean", short: "h" },
16
26
  version: { type: "boolean", short: "v" }
17
27
  };
@@ -36,7 +46,89 @@ async function runCli(args = process.argv.slice(2)) {
36
46
  return;
37
47
  }
38
48
  if (values.version || command === "version") {
39
- console.log("tricache v0.7.0");
49
+ console.log("tricache v0.8.0");
50
+ return;
51
+ }
52
+ if (command === "top") {
53
+ let targetSocket = typeof values.socket === "string" ? values.socket : void 0;
54
+ if (!targetSocket && typeof values.pid === "string") {
55
+ targetSocket = resolveIpcSocketPath(values.pid);
56
+ }
57
+ if (!targetSocket) {
58
+ const active = await findActiveSockets();
59
+ if (active.length > 0) {
60
+ targetSocket = active[0];
61
+ } else {
62
+ targetSocket = resolveIpcSocketPath(process.pid);
63
+ }
64
+ }
65
+ const client = new IpcTelemetryClient(targetSocket);
66
+ const intervalMs = typeof values.interval === "string" ? Math.max(200, parseInt(values.interval, 10)) : 1e3;
67
+ const isOnce = Boolean(values.once || !process.stdout.isTTY);
68
+ const asJson = Boolean(values.json);
69
+ if (isOnce) {
70
+ try {
71
+ const payload = await client.getMetrics();
72
+ if (asJson) {
73
+ console.log(JSON.stringify(payload, null, 2));
74
+ } else {
75
+ console.log(renderTopDashboard(payload));
76
+ }
77
+ return;
78
+ } catch (err) {
79
+ console.error(`Failed to connect to TriCache IPC at ${targetSocket}: ${err.message}`);
80
+ process.exit(1);
81
+ }
82
+ }
83
+ process.stdout.write("\x1B[?1049h\x1B[?25l");
84
+ let activeInterval = null;
85
+ let cleaningUp = false;
86
+ const cleanup = () => {
87
+ if (cleaningUp) return;
88
+ cleaningUp = true;
89
+ if (activeInterval) clearInterval(activeInterval);
90
+ if (process.stdout.isTTY) {
91
+ process.stdout.write("\x1B[?25h\x1B[?1049l");
92
+ }
93
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
94
+ try {
95
+ process.stdin.setRawMode(false);
96
+ process.stdin.pause();
97
+ } catch {
98
+ }
99
+ }
100
+ process.exit(0);
101
+ };
102
+ process.once("SIGINT", cleanup);
103
+ process.once("SIGTERM", cleanup);
104
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
105
+ try {
106
+ process.stdin.setRawMode(true);
107
+ process.stdin.resume();
108
+ process.stdin.setEncoding("utf8");
109
+ process.stdin.on("data", (key) => {
110
+ if (key === "q" || key === "Q" || key === "") {
111
+ cleanup();
112
+ }
113
+ });
114
+ } catch {
115
+ }
116
+ }
117
+ const tick = async () => {
118
+ try {
119
+ const payload = await client.getMetrics();
120
+ const screen = renderTopDashboard(payload);
121
+ process.stdout.write("\x1B[H" + screen + '\n Press "q" or Ctrl+C to exit\n');
122
+ } catch (err) {
123
+ process.stdout.write(`\x1B[HConnecting to ${targetSocket}...
124
+ Error: ${err.message}
125
+ `);
126
+ }
127
+ };
128
+ await tick();
129
+ activeInterval = setInterval(tick, intervalMs);
130
+ await new Promise(() => {
131
+ });
40
132
  return;
41
133
  }
42
134
  const redisStr = typeof values.redis === "string" ? values.redis : void 0;
@@ -111,15 +203,21 @@ Usage:
111
203
  tricache <command> [options]
112
204
 
113
205
  Commands:
206
+ top Live ASCII terminal dashboard monitoring an active TriCache process
114
207
  inspect Display full dashboard including hit ratios, latencies, and hot keys (default)
115
208
  ping Measure response latency across L1 (RAM), L1.5 (Disk), and L2 (Redis)
116
209
  clear Flush all entries or keys matching a prefix
117
210
 
118
211
  Options:
212
+ -s, --socket <path> IPC socket path or Windows named pipe
213
+ --pid <pid> Process ID of the target TriCache process to monitor
214
+ -i, --interval <ms> Refresh interval in milliseconds for top (default: 1000)
215
+ --once Output single snapshot and exit (non-interactive)
216
+ --json Format output as raw JSON
119
217
  -r, --redis <host|url> Redis connection host or URL (e.g. localhost, redis://127.0.0.1:6379)
120
218
  -p, --port <port> Redis port (default: 6379)
121
219
  -n, --namespace <ns> Cache namespace
122
- --prefix <prefix> Key prefix filter for clear command
220
+ --prefix <prefix> Key prefix filter for clear command
123
221
  -d, --disk <path> Custom disk cache directory path
124
222
  -h, --help Show this help message
125
223
  -v, --version Display version number