tricache 0.7.1 → 0.9.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 +89 -1371
- package/dashboards/prometheus-scrape.yml +18 -0
- package/dashboards/tricache-alerts.yaml +54 -0
- package/dashboards/tricache-grafana.json +548 -0
- package/dist/cache-service-DVvroyqA.d.ts +886 -0
- package/dist/cache-service-KI5ACF3F.js +12 -0
- package/dist/chunk-7RV5ZVBB.js +1023 -0
- package/dist/chunk-BQRURGGD.js +60 -0
- package/dist/chunk-IITRFWHY.js +196 -0
- package/dist/{chunk-X5AXHPVD.js → chunk-LJ5QJB5O.js} +90 -5
- package/dist/{chunk-EUGYR7KR.js → chunk-PL5J3ZNT.js} +3184 -514
- package/dist/chunk-QNU7B43J.js +687 -0
- package/dist/chunk-UGD4VEPD.js +138 -0
- package/dist/chunk-XZL45ABR.js +108 -0
- package/dist/cli.cjs +3122 -495
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +121 -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 +2846 -494
- package/dist/drizzle/index.d.ts +3 -1
- package/dist/drizzle/index.js +1 -1
- package/dist/edge/index.cjs +1559 -0
- package/dist/edge/index.d.ts +127 -0
- package/dist/edge/index.js +1109 -0
- package/dist/hono/index.cjs +7760 -0
- package/dist/hono/index.d.ts +91 -0
- package/dist/hono/index.js +185 -0
- package/dist/hono-VA9A1m0I.d.ts +371 -0
- package/dist/http/index.cjs +3281 -587
- package/dist/http/index.d.ts +85 -23
- package/dist/http/index.js +176 -78
- package/dist/index.cjs +7212 -2505
- 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 +2787 -487
- package/dist/nestjs/index.d.ts +3 -1
- package/dist/nestjs/index.js +6 -3
- package/dist/next/index.cjs +2804 -501
- package/dist/next/index.d.ts +4 -2
- package/dist/next/index.js +14 -10
- package/dist/prisma/index.d.ts +3 -1
- package/dist/serialize-worker.cjs +5 -4
- package/dist/serialize-worker.js +1 -1
- package/dist/{cache-service-D8tIXmzb.d.ts → types-B_QkVwJ7.d.ts} +622 -662
- package/dist/utils-CEsU_Z0s.d.ts +27 -0
- package/package.json +48 -10
- package/src/adapters/auto-pipeliner.ts +206 -0
- package/src/adapters/node-redis.ts +370 -0
- package/src/cache-service.ts +1619 -415
- package/src/cli.ts +137 -2
- package/src/codec.ts +72 -0
- 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 +449 -47
- 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 +284 -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 +127 -5
- package/src/hono/index.ts +316 -0
- package/src/http/express.ts +195 -0
- package/src/http/fastify.ts +260 -0
- package/src/http/index.ts +44 -258
- package/src/http/utils.ts +92 -0
- package/src/index.ts +149 -47
- package/src/ipc-telemetry.ts +509 -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 +12 -9
- package/src/next/index.ts +37 -37
- package/src/next/isr-handler.ts +105 -105
- package/src/next/types.ts +130 -130
- 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 +91 -8
- package/src/types.ts +315 -2
- 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-5GATUYAK.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,9 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CacheService
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
CacheService,
|
|
3
|
+
IpcTelemetryClient,
|
|
4
|
+
findActiveSockets,
|
|
5
|
+
renderTopDashboard,
|
|
6
|
+
resolveIpcSocketPath
|
|
7
|
+
} from "./chunk-PL5J3ZNT.js";
|
|
8
|
+
import "./chunk-LJ5QJB5O.js";
|
|
9
|
+
import "./chunk-XZL45ABR.js";
|
|
5
10
|
|
|
6
11
|
// src/cli.ts
|
|
12
|
+
import { readFileSync } from "fs";
|
|
7
13
|
import { parseArgs } from "util";
|
|
8
14
|
async function runCli(args = process.argv.slice(2)) {
|
|
9
15
|
const options = {
|
|
@@ -12,6 +18,11 @@ async function runCli(args = process.argv.slice(2)) {
|
|
|
12
18
|
namespace: { type: "string", short: "n" },
|
|
13
19
|
prefix: { type: "string" },
|
|
14
20
|
disk: { type: "string", short: "d" },
|
|
21
|
+
pid: { type: "string" },
|
|
22
|
+
socket: { type: "string", short: "s" },
|
|
23
|
+
interval: { type: "string", short: "i" },
|
|
24
|
+
once: { type: "boolean" },
|
|
25
|
+
json: { type: "boolean" },
|
|
15
26
|
help: { type: "boolean", short: "h" },
|
|
16
27
|
version: { type: "boolean", short: "v" }
|
|
17
28
|
};
|
|
@@ -36,7 +47,106 @@ async function runCli(args = process.argv.slice(2)) {
|
|
|
36
47
|
return;
|
|
37
48
|
}
|
|
38
49
|
if (values.version || command === "version") {
|
|
39
|
-
|
|
50
|
+
let version = "0.9.0";
|
|
51
|
+
try {
|
|
52
|
+
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
53
|
+
if (pkg?.version) version = pkg.version;
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
console.log(`tricache v${version}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (command === "top") {
|
|
60
|
+
let targetSocket = typeof values.socket === "string" ? values.socket : void 0;
|
|
61
|
+
if (!targetSocket && typeof values.pid === "string") {
|
|
62
|
+
targetSocket = resolveIpcSocketPath(values.pid);
|
|
63
|
+
}
|
|
64
|
+
if (!targetSocket) {
|
|
65
|
+
const active = await findActiveSockets();
|
|
66
|
+
if (active.length > 0) {
|
|
67
|
+
targetSocket = active[0];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!targetSocket) {
|
|
71
|
+
console.error("No active TriCache instances found to monitor.\n");
|
|
72
|
+
console.error("To use `tricache top`:");
|
|
73
|
+
console.error(" 1. Ensure your running application enables IPC telemetry:");
|
|
74
|
+
console.error(" const cache = new CacheService({ namespace: 'my-app', enableIpc: true, ... });\n");
|
|
75
|
+
console.error(" 2. If the application is already running, specify its PID or socket:");
|
|
76
|
+
console.error(" npx tricache top --pid <pid>");
|
|
77
|
+
console.error(" npx tricache top --socket <path>\n");
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
const client = new IpcTelemetryClient(targetSocket);
|
|
81
|
+
const intervalMs = typeof values.interval === "string" ? Math.max(200, parseInt(values.interval, 10)) : 1e3;
|
|
82
|
+
const isOnce = Boolean(values.once || !process.stdout.isTTY);
|
|
83
|
+
const asJson = Boolean(values.json);
|
|
84
|
+
if (isOnce) {
|
|
85
|
+
try {
|
|
86
|
+
const payload = await client.getMetrics();
|
|
87
|
+
if (asJson) {
|
|
88
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
89
|
+
} else {
|
|
90
|
+
console.log(renderTopDashboard(payload));
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.error(`Failed to connect to TriCache IPC at ${targetSocket}: ${err.message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
process.stdout.write("\x1B[?1049h\x1B[?25l");
|
|
99
|
+
let activeInterval = null;
|
|
100
|
+
let cleaningUp = false;
|
|
101
|
+
const cleanup = () => {
|
|
102
|
+
if (cleaningUp) return;
|
|
103
|
+
cleaningUp = true;
|
|
104
|
+
if (activeInterval) clearInterval(activeInterval);
|
|
105
|
+
if (process.stdout.isTTY) {
|
|
106
|
+
process.stdout.write("\x1B[?25h\x1B[?1049l");
|
|
107
|
+
}
|
|
108
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
109
|
+
try {
|
|
110
|
+
process.stdin.setRawMode(false);
|
|
111
|
+
process.stdin.pause();
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
process.exit(0);
|
|
116
|
+
};
|
|
117
|
+
process.once("SIGINT", cleanup);
|
|
118
|
+
process.once("SIGTERM", cleanup);
|
|
119
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
120
|
+
try {
|
|
121
|
+
process.stdin.setRawMode(true);
|
|
122
|
+
process.stdin.resume();
|
|
123
|
+
process.stdin.setEncoding("utf8");
|
|
124
|
+
process.stdin.on("data", (key) => {
|
|
125
|
+
if (key === "q" || key === "Q" || key === "") {
|
|
126
|
+
cleanup();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const tick = async () => {
|
|
133
|
+
try {
|
|
134
|
+
const payload = await client.getMetrics();
|
|
135
|
+
const screen = renderTopDashboard(payload);
|
|
136
|
+
process.stdout.write("\x1B[H" + screen + '\n Press "q" or Ctrl+C to exit\n');
|
|
137
|
+
} catch (err) {
|
|
138
|
+
process.stdout.write(`\x1B[HConnecting to ${targetSocket}...
|
|
139
|
+
Error: ${err.message}
|
|
140
|
+
|
|
141
|
+
Waiting for TriCache IPC server. Ensure the target process is running with enableIpc: true.
|
|
142
|
+
Press "q" or Ctrl+C to exit
|
|
143
|
+
`);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
await tick();
|
|
147
|
+
activeInterval = setInterval(tick, intervalMs);
|
|
148
|
+
await new Promise(() => {
|
|
149
|
+
});
|
|
40
150
|
return;
|
|
41
151
|
}
|
|
42
152
|
const redisStr = typeof values.redis === "string" ? values.redis : void 0;
|
|
@@ -111,15 +221,21 @@ Usage:
|
|
|
111
221
|
tricache <command> [options]
|
|
112
222
|
|
|
113
223
|
Commands:
|
|
224
|
+
top Live ASCII terminal dashboard monitoring an active TriCache process
|
|
114
225
|
inspect Display full dashboard including hit ratios, latencies, and hot keys (default)
|
|
115
226
|
ping Measure response latency across L1 (RAM), L1.5 (Disk), and L2 (Redis)
|
|
116
227
|
clear Flush all entries or keys matching a prefix
|
|
117
228
|
|
|
118
229
|
Options:
|
|
230
|
+
-s, --socket <path> IPC socket path or Windows named pipe
|
|
231
|
+
--pid <pid> Process ID of the target TriCache process to monitor
|
|
232
|
+
-i, --interval <ms> Refresh interval in milliseconds for top (default: 1000)
|
|
233
|
+
--once Output single snapshot and exit (non-interactive)
|
|
234
|
+
--json Format output as raw JSON
|
|
119
235
|
-r, --redis <host|url> Redis connection host or URL (e.g. localhost, redis://127.0.0.1:6379)
|
|
120
236
|
-p, --port <port> Redis port (default: 6379)
|
|
121
237
|
-n, --namespace <ns> Cache namespace
|
|
122
|
-
|
|
238
|
+
--prefix <prefix> Key prefix filter for clear command
|
|
123
239
|
-d, --disk <path> Custom disk cache directory path
|
|
124
240
|
-h, --help Show this help message
|
|
125
241
|
-v, --version Display version number
|