@tekir/cache 0.1.5 → 0.1.6
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/dist/stores/redis.d.ts +0 -2
- package/dist/stores/redis.js +2 -0
- package/package.json +1 -1
- package/src/stores/redis.ts +11 -3
package/dist/stores/redis.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ interface RedisClient {
|
|
|
5
5
|
expire(key: string, seconds: number): Promise<unknown>;
|
|
6
6
|
exists(key: string): Promise<boolean | number>;
|
|
7
7
|
del(key: string): Promise<unknown>;
|
|
8
|
-
send(command: string, args: unknown[]): Promise<unknown>;
|
|
9
|
-
connected?: boolean;
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
10
|
* Redis-backed cache store with key prefixing and optional TTL.
|
package/dist/stores/redis.js
CHANGED
|
@@ -109,6 +109,8 @@ export class RedisCacheStore {
|
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
111
|
async flush() {
|
|
112
|
+
// Structural cast: callers may pass clients with varying `send` arg
|
|
113
|
+
// types. We only need it to accept a string command and an array.
|
|
112
114
|
await this.redis.send('FLUSHDB', []);
|
|
113
115
|
}
|
|
114
116
|
}
|
package/package.json
CHANGED
package/src/stores/redis.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { CacheStore } from '../types'
|
|
2
2
|
|
|
3
|
+
// Lean shape: only the calls the cache store actually makes. `send` is
|
|
4
|
+
// intentionally absent because raw command shapes vary across clients
|
|
5
|
+
// (`@tekir/redis` typed string-only, ioredis any[], node-redis unknown[]).
|
|
6
|
+
// `flush()` invokes it through a structural cast so any client works.
|
|
3
7
|
interface RedisClient {
|
|
4
8
|
get(key: string): Promise<string | null>
|
|
5
9
|
set(key: string, value: string): Promise<unknown>
|
|
@@ -8,8 +12,10 @@ interface RedisClient {
|
|
|
8
12
|
// (node-redis, ioredis). Normalised at the call site.
|
|
9
13
|
exists(key: string): Promise<boolean | number>
|
|
10
14
|
del(key: string): Promise<unknown>
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RawSendable {
|
|
18
|
+
send(command: string, args?: unknown[]): Promise<unknown>
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
@@ -122,6 +128,8 @@ export class RedisCacheStore implements CacheStore {
|
|
|
122
128
|
* ```
|
|
123
129
|
*/
|
|
124
130
|
async flush(): Promise<void> {
|
|
125
|
-
|
|
131
|
+
// Structural cast: callers may pass clients with varying `send` arg
|
|
132
|
+
// types. We only need it to accept a string command and an array.
|
|
133
|
+
await (this.redis as unknown as RawSendable).send('FLUSHDB', [])
|
|
126
134
|
}
|
|
127
135
|
}
|