tricache 1.0.0 → 1.0.2

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 (97) hide show
  1. package/README.md +36 -28
  2. package/dist/{cache-service-pJ-nFcVj.d.ts → cache-service-B108FzER.d.ts} +63 -3
  3. package/dist/cache-service-CWI4jkS7.d.cts +963 -0
  4. package/dist/{cache-service-26GCO3UU.js → cache-service-GYPZFB7O.js} +2 -2
  5. package/dist/{chunk-IITRFWHY.js → chunk-EUKB7RKP.js} +21 -4
  6. package/dist/{chunk-2AJKEQMZ.js → chunk-H4GFLQ26.js} +7 -4
  7. package/dist/{chunk-7RV5ZVBB.js → chunk-JNSLMK4Q.js} +111 -29
  8. package/dist/chunk-OYDU3SMI.js +89 -0
  9. package/dist/{chunk-VXFTFZ5N.js → chunk-VNRDL5RA.js} +117 -138
  10. package/dist/{chunk-7SZSQS55.js → chunk-WYF7NOAT.js} +1831 -759
  11. package/dist/cli.cjs +1757 -777
  12. package/dist/cli.d.cts +12 -0
  13. package/dist/cli.js +27 -6
  14. package/dist/dashboard/index.cjs +111 -29
  15. package/dist/dashboard/index.d.cts +185 -0
  16. package/dist/dashboard/index.d.ts +5 -3
  17. package/dist/dashboard/index.js +1 -1
  18. package/dist/drizzle/index.cjs +1757 -773
  19. package/dist/drizzle/index.d.cts +46 -0
  20. package/dist/drizzle/index.d.ts +2 -2
  21. package/dist/drizzle/index.js +1 -1
  22. package/dist/edge/index.cjs +280 -153
  23. package/dist/edge/index.d.cts +127 -0
  24. package/dist/edge/index.d.ts +3 -3
  25. package/dist/edge/index.js +254 -147
  26. package/dist/hono/index.cjs +1805 -793
  27. package/dist/hono/index.d.cts +93 -0
  28. package/dist/hono/index.d.ts +7 -5
  29. package/dist/hono/index.js +16 -9
  30. package/dist/{hono-DuNvciyq.d.ts → hono-3rDMYVtY.d.ts} +23 -3
  31. package/dist/hono-C886ok3X.d.cts +391 -0
  32. package/dist/http/index.cjs +1946 -842
  33. package/dist/http/index.d.cts +103 -0
  34. package/dist/http/index.d.ts +13 -5
  35. package/dist/http/index.js +137 -57
  36. package/dist/index.cjs +2073 -937
  37. package/dist/index.d.cts +1006 -0
  38. package/dist/index.d.ts +40 -8
  39. package/dist/index.js +8 -8
  40. package/dist/murmur3-CMGw9PbV.d.cts +98 -0
  41. package/dist/nestjs/index.cjs +1849 -806
  42. package/dist/nestjs/index.d.cts +285 -0
  43. package/dist/nestjs/index.d.ts +103 -30
  44. package/dist/nestjs/index.js +115 -32
  45. package/dist/next/index.cjs +1913 -887
  46. package/dist/next/index.d.cts +232 -0
  47. package/dist/next/index.d.ts +33 -11
  48. package/dist/next/index.js +174 -107
  49. package/dist/prisma/index.cjs +11 -1
  50. package/dist/prisma/index.d.cts +62 -0
  51. package/dist/prisma/index.d.ts +2 -2
  52. package/dist/prisma/index.js +11 -1
  53. package/dist/serialize-worker.d.cts +2 -0
  54. package/dist/{types-5HXqBfAf.d.ts → types-BA4pz1A0.d.cts} +26 -9
  55. package/dist/types-BA4pz1A0.d.ts +1519 -0
  56. package/dist/{utils-CEsU_Z0s.d.ts → utils-Bvzn-rKS.d.cts} +3 -1
  57. package/dist/utils-Bvzn-rKS.d.ts +29 -0
  58. package/package.json +96 -36
  59. package/src/adapters/auto-pipeliner.ts +107 -24
  60. package/src/adapters/node-redis.ts +123 -25
  61. package/src/cache-service.ts +1238 -659
  62. package/src/cli.ts +24 -6
  63. package/src/cross-region.ts +21 -3
  64. package/src/dashboard/handler.ts +26 -6
  65. package/src/dashboard/html.ts +35 -10
  66. package/src/dashboard/index.ts +35 -13
  67. package/src/dashboard/types.ts +3 -1
  68. package/src/disk-tier.ts +171 -65
  69. package/src/edge/cache.ts +202 -129
  70. package/src/edge/hono.ts +23 -6
  71. package/src/edge/types.ts +2 -0
  72. package/src/hono/index.ts +19 -9
  73. package/src/http/express.ts +110 -26
  74. package/src/http/fastify.ts +38 -28
  75. package/src/http/utils.ts +54 -20
  76. package/src/ipc-telemetry.ts +35 -9
  77. package/src/nestjs/decorators.ts +1 -1
  78. package/src/nestjs/index.ts +2 -0
  79. package/src/nestjs/keyv-adapter.ts +68 -0
  80. package/src/nestjs/tricache.module.ts +13 -11
  81. package/src/nestjs/tricache.store.ts +51 -20
  82. package/src/nestjs/types.ts +29 -15
  83. package/src/next/cache-handler.ts +132 -57
  84. package/src/next/index.ts +1 -0
  85. package/src/next/isr-handler.ts +1 -4
  86. package/src/next/types.ts +21 -0
  87. package/src/prisma/index.ts +12 -1
  88. package/src/smart-memory-cache.ts +65 -27
  89. package/src/types.ts +27 -2
  90. package/src/utils/cgroup.ts +12 -0
  91. package/src/utils/deadline.ts +14 -0
  92. package/src/utils/diagnostics.ts +27 -0
  93. package/src/utils/redis-slot.ts +13 -0
  94. package/src/wasm/bloom-filter-wasm.ts +9 -4
  95. package/src/worker-pool.ts +17 -8
  96. package/src/wtiny-lfu.ts +20 -6
  97. package/dist/chunk-BQRURGGD.js +0 -60
@@ -0,0 +1,46 @@
1
+ import { C as CacheService } from '../cache-service-CWI4jkS7.cjs';
2
+ import { W as WrapOptions } from '../types-BA4pz1A0.cjs';
3
+ import 'crypto';
4
+
5
+ /**
6
+ * tricache/drizzle — First-class Drizzle ORM query caching wrapper for TriCache.
7
+ *
8
+ * Usage:
9
+ * import { withCache } from 'tricache/drizzle';
10
+ *
11
+ * const activeUsers = await withCache(
12
+ * db.select().from(users).where(eq(users.active, true)),
13
+ * { cache, ttl: 300, tags: ['users'] }
14
+ * );
15
+ */
16
+
17
+ interface DrizzleCacheOptions extends WrapOptions {
18
+ /** TriCache instance to use. If omitted, uses process-level singleton `CacheService.create()`. */
19
+ cache?: CacheService;
20
+ /** Explicit cache key. If omitted, automatically derived from SHA-256 hash of `{ sql, params }`. */
21
+ key?: string;
22
+ }
23
+ interface DrizzleExecutableQuery<T> {
24
+ toSQL(): {
25
+ sql: string;
26
+ params: unknown[];
27
+ };
28
+ execute?(): Promise<T>;
29
+ then?: (onfulfilled?: (value: T) => unknown, onrejected?: (reason: unknown) => unknown) => Promise<unknown>;
30
+ }
31
+ /**
32
+ * Generate a deterministic SHA-256 hash key for a Drizzle query based on its compiled SQL and parameters.
33
+ */
34
+ declare function generateDrizzleCacheKey(sqlInfo: {
35
+ sql: string;
36
+ params: unknown[];
37
+ }): string;
38
+ /**
39
+ * Wraps a Drizzle ORM query with TriCache caching.
40
+ *
41
+ * @param query Drizzle query builder or executable query instance.
42
+ * @param options Cache options including TTL, tags, SWR, priority, and optional key.
43
+ */
44
+ declare function withCache<T>(query: DrizzleExecutableQuery<T>, options?: DrizzleCacheOptions): Promise<T>;
45
+
46
+ export { type DrizzleCacheOptions, type DrizzleExecutableQuery, generateDrizzleCacheKey, withCache };
@@ -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-B108FzER.js';
2
+ import { W as WrapOptions } from '../types-BA4pz1A0.js';
3
3
  import 'crypto';
4
4
 
5
5
  /**
@@ -9,7 +9,7 @@ async function withCache(query, options = {}) {
9
9
  const { cache, key, ttl = 300, swr, priority, tags, dependsOn, refreshAhead, xfetchBeta, notFoundTtl } = options;
10
10
  let activeCache = cache;
11
11
  if (!activeCache) {
12
- const { CacheService } = await import("../cache-service-26GCO3UU.js");
12
+ const { CacheService } = await import("../cache-service-GYPZFB7O.js");
13
13
  activeCache = CacheService.create();
14
14
  }
15
15
  let cacheKey = key;