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.
Files changed (100) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +144 -1428
  3. package/bin/tricache.js +8 -8
  4. package/dashboards/tricache-alerts.yaml +54 -0
  5. package/dashboards/tricache-grafana.json +548 -0
  6. package/dist/cache-service-5MZXFIGK.js +12 -0
  7. package/dist/cache-service-CyLdpo77.d.ts +871 -0
  8. package/dist/{chunk-3XQUQBOZ.js → chunk-6PQ5MOWR.js} +2950 -523
  9. package/dist/chunk-7RV5ZVBB.js +1023 -0
  10. package/dist/{chunk-PFB5FMEY.js → chunk-LJ5QJB5O.js} +116 -20
  11. package/dist/chunk-QNU7B43J.js +687 -0
  12. package/dist/chunk-UGD4VEPD.js +138 -0
  13. package/dist/chunk-XZL45ABR.js +108 -0
  14. package/dist/chunk-ZTSWCFYO.js +135 -0
  15. package/dist/cli.cjs +2894 -518
  16. package/dist/cli.d.ts +1 -0
  17. package/dist/cli.js +103 -5
  18. package/dist/dashboard/index.cjs +1065 -0
  19. package/dist/dashboard/index.d.ts +183 -0
  20. package/dist/dashboard/index.js +22 -0
  21. package/dist/drizzle/index.cjs +2648 -508
  22. package/dist/drizzle/index.d.ts +3 -1
  23. package/dist/drizzle/index.js +1 -1
  24. package/dist/edge/index.cjs +1498 -0
  25. package/dist/edge/index.d.ts +127 -0
  26. package/dist/edge/index.js +1109 -0
  27. package/dist/hono-DQRS1Xd7.d.ts +370 -0
  28. package/dist/http/index.cjs +3038 -589
  29. package/dist/http/index.d.ts +109 -23
  30. package/dist/http/index.js +238 -62
  31. package/dist/index.cjs +6962 -2487
  32. package/dist/index.d.ts +547 -30
  33. package/dist/index.js +104 -5
  34. package/dist/murmur3-CMGw9PbV.d.ts +98 -0
  35. package/dist/nestjs/index.cjs +2586 -498
  36. package/dist/nestjs/index.d.ts +3 -1
  37. package/dist/nestjs/index.js +6 -3
  38. package/dist/next/index.cjs +2633 -519
  39. package/dist/next/index.d.ts +13 -7
  40. package/dist/next/index.js +45 -18
  41. package/dist/prisma/index.cjs +2 -1
  42. package/dist/prisma/index.d.ts +3 -1
  43. package/dist/prisma/index.js +2 -1
  44. package/dist/serialize-worker.cjs +31 -19
  45. package/dist/serialize-worker.js +1 -1
  46. package/dist/{cache-service-BblHuF3i.d.ts → types-B6krw64X.d.ts} +605 -646
  47. package/package.json +37 -7
  48. package/src/adapters/auto-pipeliner.ts +206 -0
  49. package/src/adapters/node-redis.ts +370 -0
  50. package/src/cache-service.ts +4231 -3226
  51. package/src/cli.ts +261 -143
  52. package/src/codec.ts +72 -0
  53. package/src/compression.ts +56 -63
  54. package/src/cross-region.ts +245 -0
  55. package/src/dashboard/handler.ts +392 -0
  56. package/src/dashboard/html.ts +594 -0
  57. package/src/dashboard/index.ts +195 -0
  58. package/src/dashboard/types.ts +96 -0
  59. package/src/disk-tier.ts +1223 -821
  60. package/src/drizzle/index.ts +86 -86
  61. package/src/edge/adapters/cloudflare-do.ts +130 -0
  62. package/src/edge/adapters/cloudflare-kv.ts +115 -0
  63. package/src/edge/adapters/upstash.ts +143 -0
  64. package/src/edge/cache.ts +797 -0
  65. package/src/edge/crypto.ts +182 -0
  66. package/src/edge/hono.ts +203 -0
  67. package/src/edge/index.ts +37 -0
  68. package/src/edge/types.ts +230 -0
  69. package/src/edge/utils/base64.ts +63 -0
  70. package/src/edge/utils/murmur3.ts +179 -0
  71. package/src/encryption.ts +635 -493
  72. package/src/http/express.ts +195 -0
  73. package/src/http/fastify.ts +260 -0
  74. package/src/http/index.ts +46 -223
  75. package/src/http/utils.ts +92 -0
  76. package/src/index.ts +149 -47
  77. package/src/ipc-telemetry.ts +481 -0
  78. package/src/latency-watchdog.ts +282 -0
  79. package/src/nestjs/decorators.ts +161 -161
  80. package/src/nestjs/index.ts +23 -23
  81. package/src/nestjs/tricache.module.ts +104 -104
  82. package/src/nestjs/tricache.store.ts +97 -97
  83. package/src/nestjs/types.ts +79 -79
  84. package/src/next/cache-handler.ts +271 -244
  85. package/src/next/index.ts +37 -37
  86. package/src/next/isr-handler.ts +105 -105
  87. package/src/next/types.ts +130 -130
  88. package/src/prisma/index.ts +154 -151
  89. package/src/remote-snapshot.ts +153 -0
  90. package/src/serialize-worker.ts +120 -120
  91. package/src/sigv4-snapshot-adapter.ts +260 -0
  92. package/src/smart-memory-cache.ts +1109 -1024
  93. package/src/types.ts +1199 -902
  94. package/src/utils/cgroup.ts +100 -0
  95. package/src/utils/tracing.ts +54 -0
  96. package/src/wasm/bloom-filter-wasm.ts +109 -102
  97. package/src/worker-pool.ts +299 -299
  98. package/src/wtiny-lfu.ts +624 -0
  99. package/dist/cache-service-AJASH5FX.js +0 -7
  100. package/dist/chunk-UBSR5UYA.js +0 -0
@@ -1,104 +1,104 @@
1
- import { CacheService, type CacheOptions } from '../index.js';
2
- import { TriCacheStore } from './tricache.store.js';
3
- import {
4
- TRICACHE_SERVICE,
5
- CACHE_MANAGER,
6
- type DynamicModule,
7
- type Provider,
8
- type TriCacheAsyncOptions,
9
- type TriCacheOptionsFactory,
10
- } from './types.js';
11
-
12
- /**
13
- * TriCacheModule — NestJS dynamic module providing TriCacheService and standard CacheStore.
14
- *
15
- * Can be registered synchronously via `TriCacheModule.register(options)`
16
- * or asynchronously via `TriCacheModule.registerAsync({ useFactory: ... })`.
17
- *
18
- * Exports:
19
- * - `TRICACHE_SERVICE` (`CacheService` instance)
20
- * - `CACHE_MANAGER` (`TriCacheStore` adapter conforming to @nestjs/cache-manager)
21
- */
22
- export class TriCacheModule {
23
- /**
24
- * Register TriCache module synchronously with static configuration options.
25
- */
26
- static register(options: CacheOptions = {}): DynamicModule {
27
- const cache = CacheService.create(options);
28
- const store = new TriCacheStore(cache);
29
-
30
- return {
31
- module: TriCacheModule,
32
- global: true,
33
- providers: [
34
- { provide: TRICACHE_SERVICE, useValue: cache },
35
- { provide: CACHE_MANAGER, useValue: store },
36
- ],
37
- exports: [TRICACHE_SERVICE, CACHE_MANAGER],
38
- };
39
- }
40
-
41
- /**
42
- * Register TriCache module asynchronously with factory or class injection.
43
- */
44
- static registerAsync(asyncOptions: TriCacheAsyncOptions): DynamicModule {
45
- const asyncProviders = this.createAsyncProviders(asyncOptions);
46
-
47
- return {
48
- module: TriCacheModule,
49
- global: true,
50
- imports: asyncOptions.imports || [],
51
- providers: [
52
- ...asyncProviders,
53
- {
54
- provide: CACHE_MANAGER,
55
- useFactory: (cache: any) => new TriCacheStore(cache as CacheService),
56
- inject: [TRICACHE_SERVICE],
57
- },
58
- ...(asyncOptions.extraProviders || []),
59
- ],
60
- exports: [TRICACHE_SERVICE, CACHE_MANAGER],
61
- };
62
- }
63
-
64
- private static createAsyncProviders(options: TriCacheAsyncOptions): Provider[] {
65
- if (options.useExisting || options.useFactory) {
66
- return [this.createAsyncOptionsProvider(options)];
67
- }
68
-
69
- if (options.useClass) {
70
- return [
71
- this.createAsyncOptionsProvider(options),
72
- {
73
- provide: options.useClass,
74
- useClass: options.useClass,
75
- },
76
- ];
77
- }
78
-
79
- return [];
80
- }
81
-
82
- private static createAsyncOptionsProvider(options: TriCacheAsyncOptions): Provider {
83
- if (options.useFactory) {
84
- return {
85
- provide: TRICACHE_SERVICE,
86
- useFactory: async (...args: any[]) => {
87
- const cacheOptions = await options.useFactory!(...args);
88
- return CacheService.create(cacheOptions);
89
- },
90
- inject: options.inject || [],
91
- };
92
- }
93
-
94
- const injectToken = options.useExisting || options.useClass!;
95
- return {
96
- provide: TRICACHE_SERVICE,
97
- useFactory: async (optionsFactory: any) => {
98
- const cacheOptions = await (optionsFactory as TriCacheOptionsFactory).createTriCacheOptions();
99
- return CacheService.create(cacheOptions);
100
- },
101
- inject: [injectToken],
102
- };
103
- }
104
- }
1
+ import { CacheService, type CacheOptions } from '../index.js';
2
+ import { TriCacheStore } from './tricache.store.js';
3
+ import {
4
+ TRICACHE_SERVICE,
5
+ CACHE_MANAGER,
6
+ type DynamicModule,
7
+ type Provider,
8
+ type TriCacheAsyncOptions,
9
+ type TriCacheOptionsFactory,
10
+ } from './types.js';
11
+
12
+ /**
13
+ * TriCacheModule — NestJS dynamic module providing TriCacheService and standard CacheStore.
14
+ *
15
+ * Can be registered synchronously via `TriCacheModule.register(options)`
16
+ * or asynchronously via `TriCacheModule.registerAsync({ useFactory: ... })`.
17
+ *
18
+ * Exports:
19
+ * - `TRICACHE_SERVICE` (`CacheService` instance)
20
+ * - `CACHE_MANAGER` (`TriCacheStore` adapter conforming to @nestjs/cache-manager)
21
+ */
22
+ export class TriCacheModule {
23
+ /**
24
+ * Register TriCache module synchronously with static configuration options.
25
+ */
26
+ static register(options: CacheOptions = {}): DynamicModule {
27
+ const cache = CacheService.create(options);
28
+ const store = new TriCacheStore(cache);
29
+
30
+ return {
31
+ module: TriCacheModule,
32
+ global: true,
33
+ providers: [
34
+ { provide: TRICACHE_SERVICE, useValue: cache },
35
+ { provide: CACHE_MANAGER, useValue: store },
36
+ ],
37
+ exports: [TRICACHE_SERVICE, CACHE_MANAGER],
38
+ };
39
+ }
40
+
41
+ /**
42
+ * Register TriCache module asynchronously with factory or class injection.
43
+ */
44
+ static registerAsync(asyncOptions: TriCacheAsyncOptions): DynamicModule {
45
+ const asyncProviders = this.createAsyncProviders(asyncOptions);
46
+
47
+ return {
48
+ module: TriCacheModule,
49
+ global: true,
50
+ imports: asyncOptions.imports || [],
51
+ providers: [
52
+ ...asyncProviders,
53
+ {
54
+ provide: CACHE_MANAGER,
55
+ useFactory: (cache: any) => new TriCacheStore(cache as CacheService),
56
+ inject: [TRICACHE_SERVICE],
57
+ },
58
+ ...(asyncOptions.extraProviders || []),
59
+ ],
60
+ exports: [TRICACHE_SERVICE, CACHE_MANAGER],
61
+ };
62
+ }
63
+
64
+ private static createAsyncProviders(options: TriCacheAsyncOptions): Provider[] {
65
+ if (options.useExisting || options.useFactory) {
66
+ return [this.createAsyncOptionsProvider(options)];
67
+ }
68
+
69
+ if (options.useClass) {
70
+ return [
71
+ this.createAsyncOptionsProvider(options),
72
+ {
73
+ provide: options.useClass,
74
+ useClass: options.useClass,
75
+ },
76
+ ];
77
+ }
78
+
79
+ return [];
80
+ }
81
+
82
+ private static createAsyncOptionsProvider(options: TriCacheAsyncOptions): Provider {
83
+ if (options.useFactory) {
84
+ return {
85
+ provide: TRICACHE_SERVICE,
86
+ useFactory: async (...args: any[]) => {
87
+ const cacheOptions = await options.useFactory!(...args);
88
+ return CacheService.create(cacheOptions);
89
+ },
90
+ inject: options.inject || [],
91
+ };
92
+ }
93
+
94
+ const injectToken = options.useExisting || options.useClass!;
95
+ return {
96
+ provide: TRICACHE_SERVICE,
97
+ useFactory: async (optionsFactory: any) => {
98
+ const cacheOptions = await (optionsFactory as TriCacheOptionsFactory).createTriCacheOptions();
99
+ return CacheService.create(cacheOptions);
100
+ },
101
+ inject: [injectToken],
102
+ };
103
+ }
104
+ }
@@ -1,97 +1,97 @@
1
- import type { CacheService } from '../index.js';
2
- import type { NestCacheStore } from './types.js';
3
-
4
- /**
5
- * TriCacheStore — drop-in CacheStore conforming to @nestjs/cache-manager and cache-manager v5/v6.
6
- *
7
- * Implements millisecond-based TTL semantics expected by cache-manager v5/v6
8
- * while dispatching to TriCache's three-tier engine with L1 memory, L1.5 NVMe disk spill,
9
- * and L2 Redis/Valkey tiers.
10
- */
11
- export class TriCacheStore implements NestCacheStore {
12
- constructor(public readonly cache: CacheService) {}
13
-
14
- /**
15
- * Retrieve an item from the cache.
16
- * Returns undefined on miss (matching cache-manager v5/v6 contract).
17
- */
18
- async get<T>(key: string): Promise<T | undefined> {
19
- const val = await this.cache.peek<T>(key);
20
- return val !== null ? val : undefined;
21
- }
22
-
23
- /**
24
- * Set an item in the cache.
25
- * @param key - Cache key
26
- * @param value - Cache value
27
- * @param ttl - TTL in milliseconds (0 = indefinite / default engine TTL)
28
- */
29
- async set<T>(key: string, value: T, ttl?: number): Promise<void> {
30
- const ttlSeconds = typeof ttl === 'number' && ttl > 0 ? Math.round(ttl / 1000) : (ttl === 0 ? 0 : undefined);
31
- await this.cache.set(key, value, ttlSeconds);
32
- }
33
-
34
- /**
35
- * Remove an item from the cache.
36
- */
37
- async del(key: string): Promise<void> {
38
- await this.cache.delete(key);
39
- }
40
-
41
- /**
42
- * Clear the entire cache namespace.
43
- */
44
- async reset(): Promise<void> {
45
- await this.cache.clear();
46
- }
47
-
48
- /**
49
- * Batch get multiple items from the cache.
50
- */
51
- async mget<T>(...keys: string[]): Promise<(T | undefined)[]> {
52
- if (keys.length === 0) return [];
53
- return this.cache.mget<T>(keys, async () => ({}));
54
- }
55
-
56
- /**
57
- * Batch set multiple entries with per-entry millisecond TTL.
58
- */
59
- async mset(entries: Array<{ key: string; value: unknown; ttl?: number }>): Promise<void> {
60
- if (entries.length === 0) return;
61
- const batch: Record<string, { value: unknown; ttl?: number }> = {};
62
- for (const e of entries) {
63
- batch[e.key] = {
64
- value: e.value,
65
- ttl: typeof e.ttl === 'number' && e.ttl > 0 ? Math.round(e.ttl / 1000) : (e.ttl === 0 ? 0 : undefined),
66
- };
67
- }
68
- await this.cache.mset(batch);
69
- }
70
-
71
- /**
72
- * Batch delete multiple keys.
73
- */
74
- async mdel(...keys: string[]): Promise<void> {
75
- if (keys.length === 0) return;
76
- await this.cache.mdel(keys);
77
- }
78
-
79
- /**
80
- * Scan keys currently resident in the cache.
81
- */
82
- async keys(pattern?: string): Promise<string[]> {
83
- const all: string[] = [];
84
- for (const k of this.cache.keys()) {
85
- if (!pattern || k.includes(pattern)) all.push(k);
86
- }
87
- return all;
88
- }
89
-
90
- /**
91
- * Get remaining TTL for a key in milliseconds.
92
- */
93
- async ttl(key: string): Promise<number | undefined> {
94
- const rem = this.cache.ttl(key);
95
- return rem !== null ? rem * 1000 : undefined;
96
- }
97
- }
1
+ import type { CacheService } from '../index.js';
2
+ import type { NestCacheStore } from './types.js';
3
+
4
+ /**
5
+ * TriCacheStore — drop-in CacheStore conforming to @nestjs/cache-manager and cache-manager v5/v6.
6
+ *
7
+ * Implements millisecond-based TTL semantics expected by cache-manager v5/v6
8
+ * while dispatching to TriCache's three-tier engine with L1 memory, L1.5 NVMe disk spill,
9
+ * and L2 Redis/Valkey tiers.
10
+ */
11
+ export class TriCacheStore implements NestCacheStore {
12
+ constructor(public readonly cache: CacheService) {}
13
+
14
+ /**
15
+ * Retrieve an item from the cache.
16
+ * Returns undefined on miss (matching cache-manager v5/v6 contract).
17
+ */
18
+ async get<T>(key: string): Promise<T | undefined> {
19
+ const val = await this.cache.peek<T>(key);
20
+ return val !== null ? val : undefined;
21
+ }
22
+
23
+ /**
24
+ * Set an item in the cache.
25
+ * @param key - Cache key
26
+ * @param value - Cache value
27
+ * @param ttl - TTL in milliseconds (0 = indefinite / default engine TTL)
28
+ */
29
+ async set<T>(key: string, value: T, ttl?: number): Promise<void> {
30
+ const ttlSeconds = typeof ttl === 'number' && ttl > 0 ? Math.round(ttl / 1000) : (ttl === 0 ? 0 : undefined);
31
+ await this.cache.set(key, value, ttlSeconds);
32
+ }
33
+
34
+ /**
35
+ * Remove an item from the cache.
36
+ */
37
+ async del(key: string): Promise<void> {
38
+ await this.cache.delete(key);
39
+ }
40
+
41
+ /**
42
+ * Clear the entire cache namespace.
43
+ */
44
+ async reset(): Promise<void> {
45
+ await this.cache.clear();
46
+ }
47
+
48
+ /**
49
+ * Batch get multiple items from the cache.
50
+ */
51
+ async mget<T>(...keys: string[]): Promise<(T | undefined)[]> {
52
+ if (keys.length === 0) return [];
53
+ return this.cache.mget<T>(keys, async () => ({}));
54
+ }
55
+
56
+ /**
57
+ * Batch set multiple entries with per-entry millisecond TTL.
58
+ */
59
+ async mset(entries: Array<{ key: string; value: unknown; ttl?: number }>): Promise<void> {
60
+ if (entries.length === 0) return;
61
+ const batch: Record<string, { value: unknown; ttl?: number }> = {};
62
+ for (const e of entries) {
63
+ batch[e.key] = {
64
+ value: e.value,
65
+ ttl: typeof e.ttl === 'number' && e.ttl > 0 ? Math.round(e.ttl / 1000) : (e.ttl === 0 ? 0 : undefined),
66
+ };
67
+ }
68
+ await this.cache.mset(batch);
69
+ }
70
+
71
+ /**
72
+ * Batch delete multiple keys.
73
+ */
74
+ async mdel(...keys: string[]): Promise<void> {
75
+ if (keys.length === 0) return;
76
+ await this.cache.mdel(keys);
77
+ }
78
+
79
+ /**
80
+ * Scan keys currently resident in the cache.
81
+ */
82
+ async keys(pattern?: string): Promise<string[]> {
83
+ const all: string[] = [];
84
+ for (const k of this.cache.keys()) {
85
+ if (!pattern || k.includes(pattern)) all.push(k);
86
+ }
87
+ return all;
88
+ }
89
+
90
+ /**
91
+ * Get remaining TTL for a key in milliseconds.
92
+ */
93
+ async ttl(key: string): Promise<number | undefined> {
94
+ const rem = this.cache.ttl(key);
95
+ return rem !== null ? rem * 1000 : undefined;
96
+ }
97
+ }
@@ -1,79 +1,79 @@
1
- import type { CacheOptions } from '../index.js';
2
-
3
- export const TRICACHE_SERVICE = 'TRICACHE_SERVICE';
4
- export const CACHE_MANAGER = 'CACHE_MANAGER';
5
-
6
- export type InjectionToken = string | symbol | Function | Type<unknown>;
7
-
8
- export interface Type<T = unknown> extends Function {
9
- new (...args: unknown[]): T;
10
- }
11
-
12
- export interface ForwardReference<T = unknown> {
13
- forwardRef: () => T;
14
- }
15
-
16
- export interface Abstract<T> extends Function {
17
- prototype: T;
18
- }
19
-
20
- export interface ValueProvider<T = unknown> {
21
- provide: InjectionToken;
22
- useValue: T;
23
- }
24
-
25
- export interface ClassProvider<T = unknown> {
26
- provide: InjectionToken;
27
- useClass: Type<T>;
28
- }
29
-
30
- export interface ExistingProvider {
31
- provide: InjectionToken;
32
- useExisting: InjectionToken;
33
- }
34
-
35
- export interface FactoryProvider<T = unknown> {
36
- provide: InjectionToken;
37
- useFactory: (...args: any[]) => T | Promise<T>;
38
- inject?: Array<InjectionToken | any>;
39
- }
40
-
41
- export type Provider<T = unknown> =
42
- | Type<unknown>
43
- | ValueProvider<T>
44
- | ClassProvider<T>
45
- | ExistingProvider
46
- | FactoryProvider<T>;
47
-
48
- export interface DynamicModule {
49
- module: Type<unknown>;
50
- providers?: Provider[];
51
- exports?: Array<DynamicModule | Promise<DynamicModule> | string | symbol | Provider | Function | unknown>;
52
- imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
53
- global?: boolean;
54
- }
55
-
56
- export interface TriCacheOptionsFactory {
57
- createTriCacheOptions(): Promise<CacheOptions> | CacheOptions;
58
- }
59
-
60
- export interface TriCacheAsyncOptions {
61
- imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
62
- useExisting?: Type<TriCacheOptionsFactory>;
63
- useClass?: Type<TriCacheOptionsFactory>;
64
- useFactory?: (...args: unknown[]) => Promise<CacheOptions> | CacheOptions;
65
- inject?: Array<InjectionToken | unknown>;
66
- extraProviders?: Provider[];
67
- }
68
-
69
- export interface NestCacheStore {
70
- get<T>(key: string): Promise<T | undefined>;
71
- set<T>(key: string, value: T, ttl?: number): Promise<void>;
72
- del(key: string): Promise<void>;
73
- reset(): Promise<void>;
74
- mget<T>(...keys: string[]): Promise<(T | undefined)[]>;
75
- mset(entries: Array<{ key: string; value: unknown; ttl?: number }>): Promise<void>;
76
- mdel(...keys: string[]): Promise<void>;
77
- keys(pattern?: string): Promise<string[]>;
78
- ttl(key: string): Promise<number | undefined>;
79
- }
1
+ import type { CacheOptions } from '../index.js';
2
+
3
+ export const TRICACHE_SERVICE = 'TRICACHE_SERVICE';
4
+ export const CACHE_MANAGER = 'CACHE_MANAGER';
5
+
6
+ export type InjectionToken = string | symbol | Function | Type<unknown>;
7
+
8
+ export interface Type<T = unknown> extends Function {
9
+ new (...args: unknown[]): T;
10
+ }
11
+
12
+ export interface ForwardReference<T = unknown> {
13
+ forwardRef: () => T;
14
+ }
15
+
16
+ export interface Abstract<T> extends Function {
17
+ prototype: T;
18
+ }
19
+
20
+ export interface ValueProvider<T = unknown> {
21
+ provide: InjectionToken;
22
+ useValue: T;
23
+ }
24
+
25
+ export interface ClassProvider<T = unknown> {
26
+ provide: InjectionToken;
27
+ useClass: Type<T>;
28
+ }
29
+
30
+ export interface ExistingProvider {
31
+ provide: InjectionToken;
32
+ useExisting: InjectionToken;
33
+ }
34
+
35
+ export interface FactoryProvider<T = unknown> {
36
+ provide: InjectionToken;
37
+ useFactory: (...args: any[]) => T | Promise<T>;
38
+ inject?: Array<InjectionToken | any>;
39
+ }
40
+
41
+ export type Provider<T = unknown> =
42
+ | Type<unknown>
43
+ | ValueProvider<T>
44
+ | ClassProvider<T>
45
+ | ExistingProvider
46
+ | FactoryProvider<T>;
47
+
48
+ export interface DynamicModule {
49
+ module: Type<unknown>;
50
+ providers?: Provider[];
51
+ exports?: Array<DynamicModule | Promise<DynamicModule> | string | symbol | Provider | Function | unknown>;
52
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
53
+ global?: boolean;
54
+ }
55
+
56
+ export interface TriCacheOptionsFactory {
57
+ createTriCacheOptions(): Promise<CacheOptions> | CacheOptions;
58
+ }
59
+
60
+ export interface TriCacheAsyncOptions {
61
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
62
+ useExisting?: Type<TriCacheOptionsFactory>;
63
+ useClass?: Type<TriCacheOptionsFactory>;
64
+ useFactory?: (...args: unknown[]) => Promise<CacheOptions> | CacheOptions;
65
+ inject?: Array<InjectionToken | unknown>;
66
+ extraProviders?: Provider[];
67
+ }
68
+
69
+ export interface NestCacheStore {
70
+ get<T>(key: string): Promise<T | undefined>;
71
+ set<T>(key: string, value: T, ttl?: number): Promise<void>;
72
+ del(key: string): Promise<void>;
73
+ reset(): Promise<void>;
74
+ mget<T>(...keys: string[]): Promise<(T | undefined)[]>;
75
+ mset(entries: Array<{ key: string; value: unknown; ttl?: number }>): Promise<void>;
76
+ mdel(...keys: string[]): Promise<void>;
77
+ keys(pattern?: string): Promise<string[]>;
78
+ ttl(key: string): Promise<number | undefined>;
79
+ }