tricache 1.0.0 → 1.0.1

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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/{cache-service-pJ-nFcVj.d.ts → cache-service-CREOp7MM.d.ts} +29 -1
  3. package/dist/{cache-service-26GCO3UU.js → cache-service-MG7PN6MX.js} +1 -1
  4. package/dist/{chunk-VXFTFZ5N.js → chunk-3I5L7K6I.js} +17 -0
  5. package/dist/{chunk-7SZSQS55.js → chunk-JYQFQJNJ.js} +533 -295
  6. package/dist/cli.cjs +534 -296
  7. package/dist/cli.js +2 -2
  8. package/dist/dashboard/index.d.ts +2 -2
  9. package/dist/drizzle/index.cjs +533 -295
  10. package/dist/drizzle/index.d.ts +2 -2
  11. package/dist/drizzle/index.js +1 -1
  12. package/dist/edge/index.cjs +55 -32
  13. package/dist/edge/index.d.ts +3 -3
  14. package/dist/edge/index.js +55 -32
  15. package/dist/hono/index.cjs +533 -295
  16. package/dist/hono/index.d.ts +2 -2
  17. package/dist/hono/index.js +1 -1
  18. package/dist/{hono-DuNvciyq.d.ts → hono-DSV2ve66.d.ts} +8 -1
  19. package/dist/http/index.cjs +585 -316
  20. package/dist/http/index.d.ts +3 -3
  21. package/dist/http/index.js +55 -24
  22. package/dist/index.cjs +550 -295
  23. package/dist/index.d.ts +5 -4
  24. package/dist/index.js +2 -2
  25. package/dist/nestjs/index.cjs +533 -295
  26. package/dist/nestjs/index.d.ts +2 -2
  27. package/dist/nestjs/index.js +2 -2
  28. package/dist/next/index.cjs +535 -303
  29. package/dist/next/index.d.ts +2 -2
  30. package/dist/next/index.js +3 -9
  31. package/dist/prisma/index.d.ts +2 -2
  32. package/dist/{types-5HXqBfAf.d.ts → types-Dyip5wAl.d.ts} +2 -0
  33. package/package.json +1 -1
  34. package/src/adapters/node-redis.ts +19 -0
  35. package/src/cache-service.ts +599 -320
  36. package/src/cli.ts +1 -1
  37. package/src/edge/cache.ts +60 -35
  38. package/src/http/express.ts +55 -16
  39. package/src/http/fastify.ts +3 -7
  40. package/src/next/cache-handler.ts +1 -4
  41. package/src/next/isr-handler.ts +1 -4
  42. package/src/smart-memory-cache.ts +3 -2
  43. package/src/types.ts +2 -0
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-pJ-nFcVj.js';
2
- import { C as CacheOptions, i as ILogger } from '../types-5HXqBfAf.js';
1
+ import { C as CacheService } from '../cache-service-CREOp7MM.js';
2
+ import { C as CacheOptions, i as ILogger } from '../types-Dyip5wAl.js';
3
3
  import 'crypto';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CacheService
3
- } from "../chunk-7SZSQS55.js";
3
+ } from "../chunk-JYQFQJNJ.js";
4
4
  import {
5
5
  consoleLogger
6
6
  } from "../chunk-UBWLPKTI.js";
@@ -76,10 +76,7 @@ var TriCacheHandler = class {
76
76
  * and returns a fresh unlocked ReadableStream if the stored value was a stream.
77
77
  */
78
78
  async get(cacheKey, ctx) {
79
- const stored = await this.cache.get(
80
- cacheKey,
81
- async () => null
82
- );
79
+ const stored = await this.cache.peek(cacheKey);
83
80
  if (!stored || stored.data == null) {
84
81
  return void 0;
85
82
  }
@@ -232,10 +229,7 @@ var TriCacheISRHandler = class {
232
229
  if (this.requestCache.has(key)) {
233
230
  return this.requestCache.get(key) ?? null;
234
231
  }
235
- const stored = await this.cache.get(
236
- key,
237
- async () => null
238
- );
232
+ const stored = await this.cache.peek(key);
239
233
  if (stored) {
240
234
  this.requestCache.set(key, stored);
241
235
  return stored;
@@ -1,5 +1,5 @@
1
- import { C as CacheService } from '../cache-service-pJ-nFcVj.js';
2
- import { W as WrapOptions } from '../types-5HXqBfAf.js';
1
+ import { C as CacheService } from '../cache-service-CREOp7MM.js';
2
+ import { W as WrapOptions } from '../types-Dyip5wAl.js';
3
3
  import 'crypto';
4
4
 
5
5
  /**
@@ -1436,6 +1436,7 @@ interface IRedisPipeline {
1436
1436
  sadd(key: string, ...members: string[]): this;
1437
1437
  smembers(key: string): this;
1438
1438
  hset(key: string, value: Record<string, string>): this;
1439
+ hgetall?(key: string): this;
1439
1440
  exec(): Promise<Array<[Error | null, any]> | null>;
1440
1441
  }
1441
1442
  /**
@@ -1461,6 +1462,7 @@ interface IRedisDriver {
1461
1462
  count?: number;
1462
1463
  }): any;
1463
1464
  hset?(key: string, value: Record<string, string>): Promise<unknown>;
1465
+ hgetall?(key: string): Promise<Record<string, string>>;
1464
1466
  publish?(channel: string, message: string): Promise<number>;
1465
1467
  subscribe?(...channels: string[]): Promise<unknown>;
1466
1468
  disconnect(): Promise<void> | void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tricache",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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",
@@ -84,6 +84,15 @@ export class NodeRedisPipelineAdapter implements IRedisPipeline {
84
84
  return this;
85
85
  }
86
86
 
87
+ hgetall(key: string): this {
88
+ if (typeof this.multiInstance.hGetAll === 'function') {
89
+ this.multiInstance.hGetAll(key);
90
+ } else {
91
+ this.multiInstance.hgetall(key);
92
+ }
93
+ return this;
94
+ }
95
+
87
96
  async exec(): Promise<Array<[Error | null, any]> | null> {
88
97
  const raw = await this.multiInstance.exec();
89
98
  if (!raw) return null;
@@ -252,6 +261,16 @@ export class NodeRedisAdapter implements IRedisDriver {
252
261
  return undefined;
253
262
  }
254
263
 
264
+ async hgetall(key: string): Promise<Record<string, string>> {
265
+ if (typeof this.client.hGetAll === 'function') {
266
+ return (await this.client.hGetAll(key)) ?? {};
267
+ }
268
+ if (typeof this.client.hgetall === 'function') {
269
+ return (await this.client.hgetall(key)) ?? {};
270
+ }
271
+ return {};
272
+ }
273
+
255
274
  async publish(channel: string, message: string): Promise<number> {
256
275
  return await this.client.publish(channel, message);
257
276
  }