tricache 0.8.0 → 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.
Files changed (44) hide show
  1. package/README.md +4 -2
  2. package/dashboards/prometheus-scrape.yml +18 -0
  3. package/dist/{cache-service-CyLdpo77.d.ts → cache-service-DVvroyqA.d.ts} +16 -1
  4. package/dist/{cache-service-5MZXFIGK.js → cache-service-KI5ACF3F.js} +1 -1
  5. package/dist/chunk-BQRURGGD.js +60 -0
  6. package/dist/chunk-IITRFWHY.js +196 -0
  7. package/dist/{chunk-6PQ5MOWR.js → chunk-PL5J3ZNT.js} +370 -81
  8. package/dist/cli.cjs +392 -84
  9. package/dist/cli.js +22 -4
  10. package/dist/dashboard/index.d.ts +2 -2
  11. package/dist/drizzle/index.cjs +350 -81
  12. package/dist/drizzle/index.d.ts +2 -2
  13. package/dist/drizzle/index.js +1 -1
  14. package/dist/edge/index.cjs +99 -38
  15. package/dist/edge/index.d.ts +3 -3
  16. package/dist/edge/index.js +5 -5
  17. package/dist/hono/index.cjs +7760 -0
  18. package/dist/hono/index.d.ts +91 -0
  19. package/dist/hono/index.js +185 -0
  20. package/dist/{hono-DQRS1Xd7.d.ts → hono-VA9A1m0I.d.ts} +3 -2
  21. package/dist/http/index.cjs +449 -119
  22. package/dist/http/index.d.ts +6 -30
  23. package/dist/http/index.js +9 -59
  24. package/dist/index.cjs +370 -81
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +1 -1
  27. package/dist/nestjs/index.cjs +350 -81
  28. package/dist/nestjs/index.d.ts +2 -2
  29. package/dist/nestjs/index.js +1 -1
  30. package/dist/next/index.cjs +350 -81
  31. package/dist/next/index.d.ts +2 -2
  32. package/dist/next/index.js +1 -1
  33. package/dist/prisma/index.d.ts +2 -2
  34. package/dist/{types-B6krw64X.d.ts → types-B_QkVwJ7.d.ts} +23 -0
  35. package/dist/utils-CEsU_Z0s.d.ts +27 -0
  36. package/package.json +16 -6
  37. package/src/cache-service.ts +302 -35
  38. package/src/cli.ts +21 -4
  39. package/src/edge/hono.ts +123 -42
  40. package/src/hono/index.ts +316 -0
  41. package/src/http/index.ts +5 -0
  42. package/src/ipc-telemetry.ts +29 -1
  43. package/src/types.ts +25 -0
  44. package/dist/chunk-ZTSWCFYO.js +0 -135
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-CyLdpo77.js';
2
- import { C as CacheOptions, h as ILogger } from '../types-B6krw64X.js';
1
+ import { C as CacheService } from '../cache-service-DVvroyqA.js';
2
+ import { C as CacheOptions, h as ILogger } from '../types-B_QkVwJ7.js';
3
3
  import 'crypto';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CacheService
3
- } from "../chunk-6PQ5MOWR.js";
3
+ } from "../chunk-PL5J3ZNT.js";
4
4
  import {
5
5
  consoleLogger
6
6
  } from "../chunk-LJ5QJB5O.js";
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-CyLdpo77.js';
2
- import { W as WrapOptions } from '../types-B6krw64X.js';
1
+ import { C as CacheService } from '../cache-service-DVvroyqA.js';
2
+ import { W as WrapOptions } from '../types-B_QkVwJ7.js';
3
3
  import 'crypto';
4
4
 
5
5
  /**
@@ -946,6 +946,23 @@ interface CacheOptions {
946
946
  * Default: `false` (standard cluster PUBLISH / SUBSCRIBE).
947
947
  */
948
948
  useShardedPubSub?: boolean;
949
+ /**
950
+ * If true, await backplane invalidation broadcasts during delete(), set(),
951
+ * clear(), and invalidateTag() operations rather than firing them in the background.
952
+ * Guarantees that remote cluster nodes receive the invalidation before the
953
+ * operation resolves to the caller.
954
+ *
955
+ * Default: `false` (asynchronous fire-and-forget for minimal caller latency).
956
+ */
957
+ awaitInvalidationBackplane?: boolean;
958
+ /**
959
+ * If `true`, `cache.lock()` operations fail closed (throw an Error) if Redis
960
+ * encounters a connection or runtime error during lock acquisition, preventing
961
+ * split-brain concurrent execution across multiple cluster nodes.
962
+ *
963
+ * Default: `false` (falls back to local in-process mutex with a debug log).
964
+ */
965
+ lockFailClosed?: boolean;
949
966
  /**
950
967
  * Optional cross-region invalidation relay configuration for geo-distributed deployments.
951
968
  * Synchronizes `delete()` and `invalidateTag()` events across separate regional Redis clusters
@@ -1330,6 +1347,12 @@ interface LockOptions {
1330
1347
  * Default: `100` ms.
1331
1348
  */
1332
1349
  retryInterval?: number;
1350
+ /**
1351
+ * If `true`, lock acquisition will throw an error immediately if Redis encounters a
1352
+ * connection or operational error rather than falling back to an in-process mutex.
1353
+ * Overrides `CacheOptions.lockFailClosed`.
1354
+ */
1355
+ failClosedOnRedisError?: boolean;
1333
1356
  }
1334
1357
  /**
1335
1358
  * Structural typing matching OpenTelemetry Metric interfaces (`@opentelemetry/api`).
@@ -0,0 +1,27 @@
1
+ interface KeyDerivationOptions {
2
+ /** Custom key derivation function. Overrides default URL and query string serialization. */
3
+ keyGenerator?: (req: any) => string;
4
+ /** Optional list of header names (case-insensitive) to include in the cache key. */
5
+ headerWhitelist?: string[];
6
+ }
7
+ /**
8
+ * Generates a deterministic HTTP cache key from request method, URL path, sorted query parameters,
9
+ * and optional whitelisted headers.
10
+ *
11
+ * Example:
12
+ * GET /api/products?sort=desc&page=2
13
+ * GET /api/products?page=2&sort=desc
14
+ * Both map to: http:GET:/api/products?page=2&sort=desc
15
+ */
16
+ declare function buildDeterministicKey(req: any, options?: KeyDerivationOptions): string;
17
+ /**
18
+ * Checks if request specifies Cache-Control bypass directives (no-cache, no-store)
19
+ * or matches a custom skipCache predicate.
20
+ */
21
+ declare function shouldSkipCache(req: any, customSkip?: (req: any) => boolean): boolean;
22
+ /**
23
+ * Compute a weak ETag (W/"...") from string, Buffer, or JSON-serializable object.
24
+ */
25
+ declare function generateETag(data: unknown): string;
26
+
27
+ export { type KeyDerivationOptions as K, buildDeterministicKey as b, generateETag as g, shouldSkipCache as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tricache",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Three-tier Node.js cache: L1 smart RAM (adaptive LFU/LRU + Count-Min Sketch) → L1.5 NVMe disk spill → L2 Redis/Valkey. Includes AES-256-GCM at-rest encryption, WASM Bloom filter, Stale-While-Revalidate, and thundering-herd prevention.",
5
5
  "keywords": [
6
6
  "cache",
@@ -69,6 +69,11 @@
69
69
  "import": "./dist/http/index.js",
70
70
  "require": "./dist/http/index.cjs"
71
71
  },
72
+ "./hono": {
73
+ "types": "./dist/hono/index.d.ts",
74
+ "import": "./dist/hono/index.js",
75
+ "require": "./dist/hono/index.cjs"
76
+ },
72
77
  "./dashboard": {
73
78
  "types": "./dist/dashboard/index.d.ts",
74
79
  "import": "./dist/dashboard/index.js",
@@ -93,7 +98,8 @@
93
98
  ],
94
99
  "peerDependencies": {
95
100
  "@nestjs/common": "^10.0.0 || ^11.0.0",
96
- "@nestjs/core": "^10.0.0 || ^11.0.0"
101
+ "@nestjs/core": "^10.0.0 || ^11.0.0",
102
+ "hono": ">=3.0.0 <5.0.0"
97
103
  },
98
104
  "peerDependenciesMeta": {
99
105
  "@nestjs/common": {
@@ -101,6 +107,9 @@
101
107
  },
102
108
  "@nestjs/core": {
103
109
  "optional": true
110
+ },
111
+ "hono": {
112
+ "optional": true
104
113
  }
105
114
  },
106
115
  "dependencies": {
@@ -110,12 +119,13 @@
110
119
  "devDependencies": {
111
120
  "@nestjs/common": "^11.0.0",
112
121
  "@nestjs/core": "^11.0.0",
113
- "@types/node": "^26.2.0",
122
+ "@types/node": "^26.6.2",
123
+ "hono": "^4.0.0",
114
124
  "markdown-it-mathjax3": "^4.3.2",
115
- "oxlint": "^1.79.0",
125
+ "oxlint": "^1.85.0",
116
126
  "redis": "^6.2.1",
117
127
  "tsup": "^8.5.1",
118
- "tsx": "^4.23.12",
128
+ "tsx": "^4.23.15",
119
129
  "typescript": "^6.0.3",
120
130
  "vite": "^8.2.2",
121
131
  "vitepress": "2.0.0-alpha.20",
@@ -125,7 +135,7 @@
125
135
  "node": ">=20.10.0"
126
136
  },
127
137
  "scripts": {
128
- "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/dashboard/index.ts src/edge/index.ts --format esm,cjs --dts --clean",
138
+ "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",
129
139
  "postbuild": "node --input-type=module -e \"import{readdirSync,rmSync,statSync}from'fs';import{join}from'path';function clean(d){for(const f of readdirSync(d)){const p=join(d,f);if(statSync(p).isDirectory())clean(p);else if(p.endsWith('.d.cts'))rmSync(p,{force:true});}}clean('dist');\"",
130
140
  "dev": "tsup src/index.ts src/serialize-worker.ts --format esm,cjs --dts --watch",
131
141
  "typecheck": "tsc --noEmit",