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.
- package/LICENSE +21 -21
- package/README.md +144 -1428
- package/bin/tricache.js +8 -8
- package/dashboards/tricache-alerts.yaml +54 -0
- package/dashboards/tricache-grafana.json +548 -0
- package/dist/cache-service-5MZXFIGK.js +12 -0
- package/dist/cache-service-CyLdpo77.d.ts +871 -0
- package/dist/{chunk-3XQUQBOZ.js → chunk-6PQ5MOWR.js} +2950 -523
- package/dist/chunk-7RV5ZVBB.js +1023 -0
- package/dist/{chunk-PFB5FMEY.js → chunk-LJ5QJB5O.js} +116 -20
- package/dist/chunk-QNU7B43J.js +687 -0
- package/dist/chunk-UGD4VEPD.js +138 -0
- package/dist/chunk-XZL45ABR.js +108 -0
- package/dist/chunk-ZTSWCFYO.js +135 -0
- package/dist/cli.cjs +2894 -518
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +103 -5
- package/dist/dashboard/index.cjs +1065 -0
- package/dist/dashboard/index.d.ts +183 -0
- package/dist/dashboard/index.js +22 -0
- package/dist/drizzle/index.cjs +2648 -508
- package/dist/drizzle/index.d.ts +3 -1
- package/dist/drizzle/index.js +1 -1
- package/dist/edge/index.cjs +1498 -0
- package/dist/edge/index.d.ts +127 -0
- package/dist/edge/index.js +1109 -0
- package/dist/hono-DQRS1Xd7.d.ts +370 -0
- package/dist/http/index.cjs +3038 -589
- package/dist/http/index.d.ts +109 -23
- package/dist/http/index.js +238 -62
- package/dist/index.cjs +6962 -2487
- package/dist/index.d.ts +547 -30
- package/dist/index.js +104 -5
- package/dist/murmur3-CMGw9PbV.d.ts +98 -0
- package/dist/nestjs/index.cjs +2586 -498
- package/dist/nestjs/index.d.ts +3 -1
- package/dist/nestjs/index.js +6 -3
- package/dist/next/index.cjs +2633 -519
- package/dist/next/index.d.ts +13 -7
- package/dist/next/index.js +45 -18
- package/dist/prisma/index.cjs +2 -1
- package/dist/prisma/index.d.ts +3 -1
- package/dist/prisma/index.js +2 -1
- package/dist/serialize-worker.cjs +31 -19
- package/dist/serialize-worker.js +1 -1
- package/dist/{cache-service-BblHuF3i.d.ts → types-B6krw64X.d.ts} +605 -646
- package/package.json +37 -7
- package/src/adapters/auto-pipeliner.ts +206 -0
- package/src/adapters/node-redis.ts +370 -0
- package/src/cache-service.ts +4231 -3226
- package/src/cli.ts +261 -143
- package/src/codec.ts +72 -0
- package/src/compression.ts +56 -63
- package/src/cross-region.ts +245 -0
- package/src/dashboard/handler.ts +392 -0
- package/src/dashboard/html.ts +594 -0
- package/src/dashboard/index.ts +195 -0
- package/src/dashboard/types.ts +96 -0
- package/src/disk-tier.ts +1223 -821
- package/src/drizzle/index.ts +86 -86
- package/src/edge/adapters/cloudflare-do.ts +130 -0
- package/src/edge/adapters/cloudflare-kv.ts +115 -0
- package/src/edge/adapters/upstash.ts +143 -0
- package/src/edge/cache.ts +797 -0
- package/src/edge/crypto.ts +182 -0
- package/src/edge/hono.ts +203 -0
- package/src/edge/index.ts +37 -0
- package/src/edge/types.ts +230 -0
- package/src/edge/utils/base64.ts +63 -0
- package/src/edge/utils/murmur3.ts +179 -0
- package/src/encryption.ts +635 -493
- package/src/http/express.ts +195 -0
- package/src/http/fastify.ts +260 -0
- package/src/http/index.ts +46 -223
- package/src/http/utils.ts +92 -0
- package/src/index.ts +149 -47
- package/src/ipc-telemetry.ts +481 -0
- package/src/latency-watchdog.ts +282 -0
- package/src/nestjs/decorators.ts +161 -161
- package/src/nestjs/index.ts +23 -23
- package/src/nestjs/tricache.module.ts +104 -104
- package/src/nestjs/tricache.store.ts +97 -97
- package/src/nestjs/types.ts +79 -79
- package/src/next/cache-handler.ts +271 -244
- package/src/next/index.ts +37 -37
- package/src/next/isr-handler.ts +105 -105
- package/src/next/types.ts +130 -130
- package/src/prisma/index.ts +154 -151
- package/src/remote-snapshot.ts +153 -0
- package/src/serialize-worker.ts +120 -120
- package/src/sigv4-snapshot-adapter.ts +260 -0
- package/src/smart-memory-cache.ts +1109 -1024
- package/src/types.ts +1199 -902
- package/src/utils/cgroup.ts +100 -0
- package/src/utils/tracing.ts +54 -0
- package/src/wasm/bloom-filter-wasm.ts +109 -102
- package/src/worker-pool.ts +299 -299
- package/src/wtiny-lfu.ts +624 -0
- package/dist/cache-service-AJASH5FX.js +0 -7
- 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
|
-
|
|
4
|
-
|
|
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.
|
|
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
|
-
|
|
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
|