@open-mercato/cache 0.3.2 → 0.4.2-canary-c02407ff85
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/.test-cache.json +4 -0
- package/build.mjs +61 -0
- package/dist/errors.js +12 -8
- package/dist/errors.js.map +7 -0
- package/dist/index.js +16 -7
- package/dist/index.js.map +7 -0
- package/dist/service.js +240 -287
- package/dist/service.js.map +7 -0
- package/dist/strategies/jsonfile.js +179 -194
- package/dist/strategies/jsonfile.js.map +7 -0
- package/dist/strategies/memory.js +143 -157
- package/dist/strategies/memory.js.map +7 -0
- package/dist/strategies/redis.js +292 -359
- package/dist/strategies/redis.js.map +7 -0
- package/dist/strategies/sqlite.js +164 -191
- package/dist/strategies/sqlite.js.map +7 -0
- package/dist/tenantContext.js +10 -6
- package/dist/tenantContext.js.map +7 -0
- package/dist/types.js +1 -1
- package/dist/types.js.map +7 -0
- package/jest.config.cjs +19 -0
- package/package.json +40 -12
- package/src/__tests__/memory.strategy.test.ts +15 -7
- package/tsconfig.build.json +9 -1
- package/tsconfig.json +4 -7
- package/watch.mjs +6 -0
- package/dist/errors.d.ts +0 -7
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/service.d.ts +0 -40
- package/dist/service.d.ts.map +0 -1
- package/dist/strategies/jsonfile.d.ts +0 -10
- package/dist/strategies/jsonfile.d.ts.map +0 -1
- package/dist/strategies/memory.d.ts +0 -9
- package/dist/strategies/memory.d.ts.map +0 -1
- package/dist/strategies/redis.d.ts +0 -5
- package/dist/strategies/redis.d.ts.map +0 -1
- package/dist/strategies/sqlite.d.ts +0 -13
- package/dist/strategies/sqlite.d.ts.map +0 -1
- package/dist/tenantContext.d.ts +0 -4
- package/dist/tenantContext.d.ts.map +0 -1
- package/dist/types.d.ts +0 -86
- package/dist/types.d.ts.map +0 -1
- package/jest.config.js +0 -19
|
@@ -55,24 +55,33 @@ describe('Memory Cache Strategy', () => {
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
describe('TTL and expiration', () => {
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
jest.useFakeTimers()
|
|
60
|
+
jest.setSystemTime(new Date('2025-01-01T00:00:00.000Z'))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
jest.useRealTimers()
|
|
65
|
+
})
|
|
66
|
+
|
|
58
67
|
it('should expire after TTL', async () => {
|
|
59
68
|
await cache.set('key1', 'value1', { ttl: 100 }) // 100ms
|
|
60
69
|
expect(await cache.get('key1')).toBe('value1')
|
|
61
70
|
|
|
62
|
-
await
|
|
71
|
+
await jest.advanceTimersByTimeAsync(150)
|
|
63
72
|
expect(await cache.get('key1')).toBeNull()
|
|
64
73
|
expect(await cache.has('key1')).toBe(false)
|
|
65
74
|
})
|
|
66
75
|
|
|
67
76
|
it('should not expire without TTL', async () => {
|
|
68
77
|
await cache.set('key1', 'value1')
|
|
69
|
-
await
|
|
78
|
+
await jest.advanceTimersByTimeAsync(100)
|
|
70
79
|
expect(await cache.get('key1')).toBe('value1')
|
|
71
80
|
})
|
|
72
81
|
|
|
73
82
|
it('should return expired value if returnExpired is true', async () => {
|
|
74
83
|
await cache.set('key1', 'value1', { ttl: 50 })
|
|
75
|
-
await
|
|
84
|
+
await jest.advanceTimersByTimeAsync(100)
|
|
76
85
|
const value = await cache.get('key1', { returnExpired: true })
|
|
77
86
|
expect(value).toBe('value1')
|
|
78
87
|
})
|
|
@@ -82,7 +91,7 @@ describe('Memory Cache Strategy', () => {
|
|
|
82
91
|
await cacheWithTtl.set('key1', 'value1') // Should use default TTL
|
|
83
92
|
expect(await cacheWithTtl.get('key1')).toBe('value1')
|
|
84
93
|
|
|
85
|
-
await
|
|
94
|
+
await jest.advanceTimersByTimeAsync(150)
|
|
86
95
|
expect(await cacheWithTtl.get('key1')).toBeNull()
|
|
87
96
|
})
|
|
88
97
|
|
|
@@ -90,10 +99,10 @@ describe('Memory Cache Strategy', () => {
|
|
|
90
99
|
const cacheWithTtl = createMemoryStrategy({ defaultTtl: 100 })
|
|
91
100
|
await cacheWithTtl.set('key1', 'value1', { ttl: 200 })
|
|
92
101
|
|
|
93
|
-
await
|
|
102
|
+
await jest.advanceTimersByTimeAsync(150)
|
|
94
103
|
expect(await cacheWithTtl.get('key1')).toBe('value1') // Still valid
|
|
95
104
|
|
|
96
|
-
await
|
|
105
|
+
await jest.advanceTimersByTimeAsync(100)
|
|
97
106
|
expect(await cacheWithTtl.get('key1')).toBeNull() // Now expired
|
|
98
107
|
})
|
|
99
108
|
})
|
|
@@ -242,4 +251,3 @@ describe('Memory Cache Strategy', () => {
|
|
|
242
251
|
})
|
|
243
252
|
})
|
|
244
253
|
})
|
|
245
|
-
|
package/tsconfig.build.json
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "
|
|
3
|
+
"extends": "../../tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"noEmit": false,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"rootDir": "./src"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*"],
|
|
4
12
|
"exclude": ["src/**/__tests__/**/*", "src/**/*.test.ts"]
|
|
5
13
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"extends": "../../tsconfig.json",
|
|
3
|
+
"extends": "../../tsconfig.base.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"noEmit":
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": "./src"
|
|
5
|
+
"noEmit": true
|
|
10
6
|
},
|
|
11
|
-
"include": ["src/**/*"]
|
|
7
|
+
"include": ["src/**/*"],
|
|
8
|
+
"exclude": ["node_modules", "dist", "**/__tests__/**"]
|
|
12
9
|
}
|
package/watch.mjs
ADDED
package/dist/errors.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare class CacheDependencyUnavailableError extends Error {
|
|
2
|
-
readonly strategy: string;
|
|
3
|
-
readonly dependency: string;
|
|
4
|
-
readonly originalError?: unknown;
|
|
5
|
-
constructor(strategy: string, dependency: string, originalError?: unknown);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,+BAAgC,SAAQ,KAAK;IACxD,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC,SAAgB,UAAU,EAAE,MAAM,CAAA;IAClC,SAAgB,aAAa,CAAC,EAAE,OAAO,CAAA;gBAE3B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAO1E"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './service';
|
|
3
|
-
export { createMemoryStrategy } from './strategies/memory';
|
|
4
|
-
export { createRedisStrategy } from './strategies/redis';
|
|
5
|
-
export { createSqliteStrategy } from './strategies/sqlite';
|
|
6
|
-
export { createJsonFileStrategy } from './strategies/jsonfile';
|
|
7
|
-
export { runWithCacheTenant, getCurrentCacheTenant } from './tenantContext';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/service.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { CacheStrategy, CacheServiceOptions, CacheGetOptions, CacheSetOptions, CacheValue } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Cache service that provides a unified interface to different cache strategies
|
|
4
|
-
*
|
|
5
|
-
* Configuration via environment variables:
|
|
6
|
-
* - CACHE_STRATEGY: 'memory' | 'redis' | 'sqlite' | 'jsonfile' (default: 'memory')
|
|
7
|
-
* - CACHE_TTL: Default TTL in milliseconds (optional)
|
|
8
|
-
* - CACHE_REDIS_URL: Redis connection URL (for redis strategy)
|
|
9
|
-
* - CACHE_SQLITE_PATH: SQLite database file path (for sqlite strategy)
|
|
10
|
-
* - CACHE_JSON_FILE_PATH: JSON file path (for jsonfile strategy)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const cache = createCacheService({ strategy: 'memory', defaultTtl: 60000 })
|
|
14
|
-
* await cache.set('user:123', { name: 'John' }, { tags: ['users', 'user:123'] })
|
|
15
|
-
* const user = await cache.get('user:123')
|
|
16
|
-
* await cache.deleteByTags(['users']) // Invalidate all user-related cache
|
|
17
|
-
*/
|
|
18
|
-
export declare function createCacheService(options?: CacheServiceOptions): CacheStrategy;
|
|
19
|
-
/**
|
|
20
|
-
* CacheService class wrapper for DI integration
|
|
21
|
-
* Provides the same interface as the functional API but as a class
|
|
22
|
-
*/
|
|
23
|
-
export declare class CacheService implements CacheStrategy {
|
|
24
|
-
private strategy;
|
|
25
|
-
constructor(options?: CacheServiceOptions);
|
|
26
|
-
get(key: string, options?: CacheGetOptions): Promise<CacheValue | null>;
|
|
27
|
-
set(key: string, value: CacheValue, options?: CacheSetOptions): Promise<void>;
|
|
28
|
-
has(key: string): Promise<boolean>;
|
|
29
|
-
delete(key: string): Promise<boolean>;
|
|
30
|
-
deleteByTags(tags: string[]): Promise<number>;
|
|
31
|
-
clear(): Promise<number>;
|
|
32
|
-
keys(pattern?: string): Promise<string[]>;
|
|
33
|
-
stats(): Promise<{
|
|
34
|
-
size: number;
|
|
35
|
-
expired: number;
|
|
36
|
-
}>;
|
|
37
|
-
cleanup(): Promise<number>;
|
|
38
|
-
close(): Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AA6M/G;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAc/E;AAED;;;GAGG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,QAAQ,CAAe;gBAEnB,OAAO,CAAC,EAAE,mBAAmB;IAInC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAIvE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7E,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzC,KAAK,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAInD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAO1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CacheStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* JSON file cache strategy with tag support
|
|
4
|
-
* Persistent across process restarts, stored in JSON files
|
|
5
|
-
* Simple and requires no external dependencies, but not suitable for high-performance scenarios
|
|
6
|
-
*/
|
|
7
|
-
export declare function createJsonFileStrategy(filePath?: string, options?: {
|
|
8
|
-
defaultTtl?: number;
|
|
9
|
-
}): CacheStrategy;
|
|
10
|
-
//# sourceMappingURL=jsonfile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonfile.d.ts","sourceRoot":"","sources":["../../src/strategies/jsonfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA4D,MAAM,UAAU,CAAA;AAIvG;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CA+O1G"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CacheStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* In-memory cache strategy with tag support
|
|
4
|
-
* Fast but data is lost when process restarts
|
|
5
|
-
*/
|
|
6
|
-
export declare function createMemoryStrategy(options?: {
|
|
7
|
-
defaultTtl?: number;
|
|
8
|
-
}): CacheStrategy;
|
|
9
|
-
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/strategies/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA4D,MAAM,UAAU,CAAA;AAEvG;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAkLrF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/strategies/redis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA4D,MAAM,UAAU,CAAA;AAwJvG,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAkSvG"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CacheStrategy } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* SQLite cache strategy with tag support
|
|
4
|
-
* Persistent across process restarts, stored in a SQLite database file
|
|
5
|
-
*
|
|
6
|
-
* Uses two tables:
|
|
7
|
-
* - cache_entries: stores cache data
|
|
8
|
-
* - cache_tags: stores tag associations (many-to-many)
|
|
9
|
-
*/
|
|
10
|
-
export declare function createSqliteStrategy(dbPath?: string, options?: {
|
|
11
|
-
defaultTtl?: number;
|
|
12
|
-
}): CacheStrategy;
|
|
13
|
-
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/strategies/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgD,MAAM,UAAU,CAAA;AAuB3F;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CA6PtG"}
|
package/dist/tenantContext.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function runWithCacheTenant<T>(tenantId: string | null, fn: () => T): T;
|
|
2
|
-
export declare function runWithCacheTenant<T>(tenantId: string | null, fn: () => Promise<T>): Promise<T>;
|
|
3
|
-
export declare function getCurrentCacheTenant(): string | null;
|
|
4
|
-
//# sourceMappingURL=tenantContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tenantContext.d.ts","sourceRoot":"","sources":["../src/tenantContext.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;AAC9E,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AAKhG,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAErD"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
export type CacheValue = unknown;
|
|
2
|
-
export type CacheEntry = {
|
|
3
|
-
key: string;
|
|
4
|
-
value: CacheValue;
|
|
5
|
-
tags: string[];
|
|
6
|
-
expiresAt: number | null;
|
|
7
|
-
createdAt: number;
|
|
8
|
-
};
|
|
9
|
-
export type CacheOptions = {
|
|
10
|
-
ttl?: number;
|
|
11
|
-
tags?: string[];
|
|
12
|
-
};
|
|
13
|
-
export type CacheGetOptions = {
|
|
14
|
-
returnExpired?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type CacheSetOptions = CacheOptions;
|
|
17
|
-
export type CacheStrategy = {
|
|
18
|
-
/**
|
|
19
|
-
* Get a value from cache
|
|
20
|
-
* @param key - Cache key
|
|
21
|
-
* @param options - Get options
|
|
22
|
-
* @returns The cached value or null if not found or expired
|
|
23
|
-
*/
|
|
24
|
-
get(key: string, options?: CacheGetOptions): Promise<CacheValue | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Set a value in cache
|
|
27
|
-
* @param key - Cache key
|
|
28
|
-
* @param value - Value to cache
|
|
29
|
-
* @param options - Cache options (ttl, tags)
|
|
30
|
-
*/
|
|
31
|
-
set(key: string, value: CacheValue, options?: CacheSetOptions): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Check if a key exists in cache (and is not expired)
|
|
34
|
-
* @param key - Cache key
|
|
35
|
-
* @returns true if key exists and is not expired
|
|
36
|
-
*/
|
|
37
|
-
has(key: string): Promise<boolean>;
|
|
38
|
-
/**
|
|
39
|
-
* Delete a specific key from cache
|
|
40
|
-
* @param key - Cache key
|
|
41
|
-
* @returns true if key was deleted, false if not found
|
|
42
|
-
*/
|
|
43
|
-
delete(key: string): Promise<boolean>;
|
|
44
|
-
/**
|
|
45
|
-
* Delete all keys with specified tags
|
|
46
|
-
* @param tags - Tags to match (any key with ANY of these tags will be deleted)
|
|
47
|
-
* @returns Number of keys deleted
|
|
48
|
-
*/
|
|
49
|
-
deleteByTags(tags: string[]): Promise<number>;
|
|
50
|
-
/**
|
|
51
|
-
* Clear all cache entries
|
|
52
|
-
* @returns Number of keys deleted
|
|
53
|
-
*/
|
|
54
|
-
clear(): Promise<number>;
|
|
55
|
-
/**
|
|
56
|
-
* Get all keys matching a pattern
|
|
57
|
-
* @param pattern - Pattern to match (supports wildcards: * and ?)
|
|
58
|
-
* @returns Array of matching keys
|
|
59
|
-
*/
|
|
60
|
-
keys(pattern?: string): Promise<string[]>;
|
|
61
|
-
/**
|
|
62
|
-
* Get cache statistics
|
|
63
|
-
* @returns Statistics object
|
|
64
|
-
*/
|
|
65
|
-
stats(): Promise<{
|
|
66
|
-
size: number;
|
|
67
|
-
expired: number;
|
|
68
|
-
}>;
|
|
69
|
-
/**
|
|
70
|
-
* Clean up expired entries (optional, some strategies may auto-cleanup)
|
|
71
|
-
* @returns Number of entries removed
|
|
72
|
-
*/
|
|
73
|
-
cleanup?(): Promise<number>;
|
|
74
|
-
/**
|
|
75
|
-
* Close/disconnect the cache strategy
|
|
76
|
-
*/
|
|
77
|
-
close?(): Promise<void>;
|
|
78
|
-
};
|
|
79
|
-
export type CacheServiceOptions = {
|
|
80
|
-
strategy?: 'memory' | 'redis' | 'sqlite' | 'jsonfile';
|
|
81
|
-
redisUrl?: string;
|
|
82
|
-
sqlitePath?: string;
|
|
83
|
-
jsonFilePath?: string;
|
|
84
|
-
defaultTtl?: number;
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,CAAA;AAEhC,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,CAAA;AAE1C,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAA;IAEvE;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7E;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAElC;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAErC;;;;OAIG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE7C;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAExB;;;;OAIG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAEzC;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC;QACf,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC,CAAA;IAEF;;;OAGG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAE3B;;OAEG;IACH,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA"}
|
package/jest.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
roots: ['<rootDir>/src'],
|
|
5
|
-
testMatch: ['**/__tests__/**/*.test.ts'],
|
|
6
|
-
transform: {
|
|
7
|
-
'^.+\\.ts$': ['ts-jest', {
|
|
8
|
-
tsconfig: {
|
|
9
|
-
esModuleInterop: true,
|
|
10
|
-
allowSyntheticDefaultImports: true,
|
|
11
|
-
},
|
|
12
|
-
}],
|
|
13
|
-
},
|
|
14
|
-
moduleNameMapper: {
|
|
15
|
-
'^@open-mercato/cache$': '<rootDir>/src/index.ts',
|
|
16
|
-
'^@open-mercato/cache/(.*)$': '<rootDir>/src/$1',
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
|