ts-server-lib 0.0.27
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/LICENSE +1 -0
- package/README.md +8 -0
- package/db/TSMongo.d.ts +103 -0
- package/db/TSMongo.js +483 -0
- package/db/TSRQW.d.ts +277 -0
- package/db/TSRQW.js +638 -0
- package/db/TSRedis.d.ts +372 -0
- package/db/TSRedis.js +955 -0
- package/package.json +85 -0
- package/ussd/TSUssdMenu.d.ts +139 -0
- package/ussd/TSUssdMenu.js +364 -0
- package/ussd/TSUssdScreen.d.ts +58 -0
- package/ussd/TSUssdScreen.js +218 -0
- package/ussd/index.d.ts +3 -0
- package/ussd/index.js +19 -0
- package/ussd/providers/AfricasTalking.d.ts +3 -0
- package/ussd/providers/AfricasTalking.js +17 -0
- package/ussd/providers/AirtelDRC.d.ts +9 -0
- package/ussd/providers/AirtelDRC.js +31 -0
- package/ussd/providers/OrangeDRC.d.ts +5 -0
- package/ussd/providers/OrangeDRC.js +213 -0
- package/ussd/providers/VodacomDRC.d.ts +9 -0
- package/ussd/providers/VodacomDRC.js +48 -0
- package/ussd/providers/_.d.ts +55 -0
- package/ussd/providers/_.js +83 -0
- package/ussd/providers/index.d.ts +13 -0
- package/ussd/providers/index.js +56 -0
- package/utils/TSFile.d.ts +36 -0
- package/utils/TSFile.js +244 -0
- package/utils/TSHash.d.ts +19 -0
- package/utils/TSHash.js +71 -0
- package/utils/TSRequest.d.ts +42 -0
- package/utils/TSRequest.js +282 -0
- package/utils/TSStub.d.ts +159 -0
- package/utils/TSStub.js +296 -0
- package/utils/abort.d.ts +18 -0
- package/utils/abort.js +97 -0
- package/utils/mime.json +11358 -0
package/db/TSRedis.d.ts
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TSRedis – Single file for Redis: connection (standalone/Sentinel), events (pub/sub), operations.
|
|
3
|
+
*/
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { type RedisClientType, type RedisClusterType, type RedisSentinelType } from 'redis';
|
|
6
|
+
export type TSRedisClient = RedisClientType | RedisClusterType | RedisSentinelType;
|
|
7
|
+
export type TSRedisPattern = {
|
|
8
|
+
match?: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
} | string;
|
|
11
|
+
export type TSRedisScan = {
|
|
12
|
+
pattern?: TSRedisPattern;
|
|
13
|
+
COUNT?: number;
|
|
14
|
+
};
|
|
15
|
+
export type TSRedisCallback = (data: unknown, k?: string) => unknown;
|
|
16
|
+
export interface RedisSentinelConfig {
|
|
17
|
+
hosts: Array<{
|
|
18
|
+
host: string;
|
|
19
|
+
port: number;
|
|
20
|
+
}>;
|
|
21
|
+
name: string;
|
|
22
|
+
/** Auth password for the sentinel nodes themselves (rare — only when sentinels have requirepass). */
|
|
23
|
+
password?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Remap master/replica addresses announced by sentinel to client-reachable addresses.
|
|
26
|
+
* Useful when sentinel runs in Docker/k8s on a different network than the client
|
|
27
|
+
* (e.g. sentinel announces 172.x.x.x:6379 but client must connect via 127.0.0.1:6381).
|
|
28
|
+
*/
|
|
29
|
+
nodeAddressMap?: RedisClusterConfig['nodeAddressMap'];
|
|
30
|
+
}
|
|
31
|
+
export interface RedisReplicaConfig {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
urls?: string[];
|
|
34
|
+
strategy?: 'round-robin' | 'random' | 'first-available';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Redis Cluster connection config. When set on `RedisConfig`, `TSRedis.connect()` creates
|
|
38
|
+
* a `createCluster()` client instead of `createClient()` and stores it as the active client.
|
|
39
|
+
*
|
|
40
|
+
* Multi-key constraints: commands that touch >1 key (`mGet`, `mSet`, `multi().chain`, custom
|
|
41
|
+
* Lua) require all keys to hash to the same slot. Use {tag} hash tags
|
|
42
|
+
* (e.g. `wallet:{tenantId:userId}:bal`) so co-located keys land on the same node.
|
|
43
|
+
*
|
|
44
|
+
* Caveat for queue consumers: TSRQW is built for the standalone client API. In cluster
|
|
45
|
+
* deployments, pass a standalone client to TSRQW (or a dedicated connection to one node)
|
|
46
|
+
* — see TSRedis.md §"Tuning and deployment".
|
|
47
|
+
*/
|
|
48
|
+
export interface RedisClusterConfig {
|
|
49
|
+
/** Seed nodes — node-redis discovers the rest via CLUSTER SLOTS after connect. */
|
|
50
|
+
nodes: Array<{
|
|
51
|
+
host: string;
|
|
52
|
+
port: number;
|
|
53
|
+
}>;
|
|
54
|
+
/** When true, route read-only commands (GET, MGET, …) to replicas. Default false (read from masters). */
|
|
55
|
+
useReplicas?: boolean;
|
|
56
|
+
/** Cluster-wide password (most clusters share one). */
|
|
57
|
+
password?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional remap of cluster-announced addresses. Cluster nodes typically announce docker
|
|
60
|
+
* hostnames (e.g. `ms-redis-3`) which aren't resolvable from a host-machine validator;
|
|
61
|
+
* supply this map to rewrite each discovered address to a client-reachable one
|
|
62
|
+
* (e.g. `127.0.0.1:7003`). Form: object map keyed by `host:port`, OR a function returning
|
|
63
|
+
* `{ host, port }` per discovered address string.
|
|
64
|
+
*/
|
|
65
|
+
nodeAddressMap?: Record<string, {
|
|
66
|
+
host: string;
|
|
67
|
+
port: number;
|
|
68
|
+
}> | ((address: string) => {
|
|
69
|
+
host: string;
|
|
70
|
+
port: number;
|
|
71
|
+
} | undefined);
|
|
72
|
+
}
|
|
73
|
+
export interface RedisConfig {
|
|
74
|
+
url: string;
|
|
75
|
+
connectTimeout?: number;
|
|
76
|
+
socketTimeout?: number;
|
|
77
|
+
autoReconnect?: boolean;
|
|
78
|
+
maxReconnectRetries?: number;
|
|
79
|
+
reconnectDelay?: number;
|
|
80
|
+
clientName?: string;
|
|
81
|
+
pingInterval?: number;
|
|
82
|
+
commandsQueueMaxLength?: number;
|
|
83
|
+
disableOfflineQueue?: boolean;
|
|
84
|
+
sentinel?: RedisSentinelConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Redis Cluster mode. Mutually exclusive with `sentinel` and `readReplicas` (the cluster
|
|
87
|
+
* client handles replica routing internally via `useReplicas`).
|
|
88
|
+
* When set, `TSRedis.connect()` creates a cluster client; `TSRedis.getCluster()` returns it.
|
|
89
|
+
* `TSRedis.getClient()` returns null in cluster mode (singleton client variable stays null);
|
|
90
|
+
* callers needing the cluster client should use `TSRedis.getCluster()` or `TSRedis.getActiveClient()`.
|
|
91
|
+
*/
|
|
92
|
+
cluster?: RedisClusterConfig;
|
|
93
|
+
readReplicas?: RedisReplicaConfig;
|
|
94
|
+
}
|
|
95
|
+
export interface ScanOptions {
|
|
96
|
+
pattern?: string;
|
|
97
|
+
count?: number;
|
|
98
|
+
maxKeys?: number;
|
|
99
|
+
batchSize?: number;
|
|
100
|
+
}
|
|
101
|
+
export interface RedisConnectionStats {
|
|
102
|
+
connected: boolean;
|
|
103
|
+
mode: 'standalone' | 'sentinel' | 'cluster';
|
|
104
|
+
hasReadReplica: boolean;
|
|
105
|
+
master: {
|
|
106
|
+
connected: boolean;
|
|
107
|
+
};
|
|
108
|
+
replica: {
|
|
109
|
+
connected: boolean;
|
|
110
|
+
count: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Flat topology descriptor — the single input shape for TSRedis.connectFromTopology().
|
|
115
|
+
*
|
|
116
|
+
* All values are explicit. The library never reads process.env inside this path —
|
|
117
|
+
* password, nodes, and mode come entirely from the caller's config snapshot.
|
|
118
|
+
*
|
|
119
|
+
* Usage pattern:
|
|
120
|
+
* const descriptor = buildRedisDescriptor(myConfig);
|
|
121
|
+
* await TSRedis.connectFromTopology(descriptor);
|
|
122
|
+
* const config = TSRedis.buildConfigFromTopology(descriptor); // if another API needs RedisConfig
|
|
123
|
+
*/
|
|
124
|
+
export interface RedisTopologyDescriptor {
|
|
125
|
+
mode: 'single' | 'sentinel' | 'cluster';
|
|
126
|
+
/** Redis URL (redis://[:password@]host:port). Used directly for single mode; provides the
|
|
127
|
+
* seed URL for cluster; ignored for sentinel (connection is driven by sentinel nodes). */
|
|
128
|
+
url?: string;
|
|
129
|
+
/** Auth password for the Redis master / standalone server. No env-var fallback. */
|
|
130
|
+
password?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Sentinel: auth password for the sentinel nodes themselves.
|
|
133
|
+
* Only needed when sentinels are configured with 'requirepass'.
|
|
134
|
+
* Most setups only password-protect the master — in that case leave this unset.
|
|
135
|
+
*/
|
|
136
|
+
sentinelPassword?: string;
|
|
137
|
+
/** Sentinel: quorum-monitor node addresses. Required when mode === 'sentinel'. */
|
|
138
|
+
sentinelNodes?: Array<{
|
|
139
|
+
host: string;
|
|
140
|
+
port: number;
|
|
141
|
+
}>;
|
|
142
|
+
/** Sentinel master set name (default 'mymaster'). */
|
|
143
|
+
sentinelMaster?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Sentinel: remap master/replica addresses announced by sentinel to client-reachable addresses.
|
|
146
|
+
* Useful when sentinel runs in Docker/k8s on a different network than the client.
|
|
147
|
+
* Also readable from env via REDIS_SENTINEL_MASTER_HOST + REDIS_SENTINEL_MASTER_PORT
|
|
148
|
+
* (sets a static remap for all announced addresses).
|
|
149
|
+
*/
|
|
150
|
+
sentinelNodeAddressMap?: RedisClusterConfig['nodeAddressMap'];
|
|
151
|
+
/** Cluster: seed nodes — node-redis discovers the rest via CLUSTER SLOTS. Required when mode === 'cluster'. */
|
|
152
|
+
clusterNodes?: Array<{
|
|
153
|
+
host: string;
|
|
154
|
+
port: number;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Cluster: optional address rewriter for MOVED redirect handling.
|
|
158
|
+
* Used by test runners behind Docker/k8s port-forwards where cluster-announced
|
|
159
|
+
* hostnames are not directly reachable from the host.
|
|
160
|
+
*/
|
|
161
|
+
clusterNodeAddressMap?: RedisClusterConfig['nodeAddressMap'];
|
|
162
|
+
maxReconnectRetries?: number;
|
|
163
|
+
reconnectDelay?: number;
|
|
164
|
+
connectTimeout?: number;
|
|
165
|
+
}
|
|
166
|
+
export declare function errMsg(e: unknown): string;
|
|
167
|
+
/** True when a node-redis client handle is open/ready (false after max-reconnect exhaustion). */
|
|
168
|
+
export declare function isClientOpen(c: TSRedisClient | null | undefined): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* True when an error indicates the caller is using a closed or half-open Redis / cluster client.
|
|
171
|
+
* Used by queue/cron recovery paths after max-reconnect exhaustion or cluster slot churn.
|
|
172
|
+
*/
|
|
173
|
+
export declare function isStaleConnectionError(err: unknown): boolean;
|
|
174
|
+
declare function connectRedisImpl(urlOrConfig: string | RedisConfig): Promise<RedisClientType>;
|
|
175
|
+
declare function getRedisImpl(): RedisClientType | null;
|
|
176
|
+
/**
|
|
177
|
+
/** Returns the active cluster client when `connectRedisImpl` was called with `config.cluster`, else null. */
|
|
178
|
+
declare function getRedisClusterImpl(): RedisClusterType | null;
|
|
179
|
+
/**
|
|
180
|
+
* Returns whichever client backs the active singleton: standalone, sentinel, or cluster.
|
|
181
|
+
* Use this when the code path is topology-agnostic (e.g. health checks, GET/SET on a single key).
|
|
182
|
+
* For multi-key ops you still need to know cluster mode to enforce hash-tag co-location.
|
|
183
|
+
*/
|
|
184
|
+
declare function getActiveClientImpl(): TSRedisClient | null;
|
|
185
|
+
/** True when TSRedis holds an active singleton client that is open (not post-max-reconnect closed). */
|
|
186
|
+
export declare function isActiveClientConnected(): boolean;
|
|
187
|
+
declare function getRedisForReadImpl(): RedisClientType | null;
|
|
188
|
+
declare function hasReadReplicaImpl(): boolean;
|
|
189
|
+
declare function checkRedisHealthImpl(): Promise<{
|
|
190
|
+
healthy: boolean;
|
|
191
|
+
latencyMs: number;
|
|
192
|
+
}>;
|
|
193
|
+
declare function publishImpl(channel: string, message: string): Promise<boolean>;
|
|
194
|
+
declare function subscribeImpl(channel: string, handler: (message: string) => void): Promise<() => Promise<void>>;
|
|
195
|
+
declare function scanKeysIteratorImpl(options?: ScanOptions): AsyncGenerator<string, void, unknown>;
|
|
196
|
+
declare function batchGetValuesImpl(keys: string[]): Promise<Record<string, string | null>>;
|
|
197
|
+
/** True when `client` is a Redis Cluster client (has a `masters` array). */
|
|
198
|
+
declare function isClusterImpl(client: TSRedisClient): client is RedisClusterType;
|
|
199
|
+
/**
|
|
200
|
+
* Topology-aware MGET with CROSSSLOT fallback.
|
|
201
|
+
*
|
|
202
|
+
* Fast path: single `mGet` round-trip (correct when all keys share a hash tag / same slot).
|
|
203
|
+
* Cluster CROSSSLOT path: falls back to per-key GETs via `Promise.all` — N parallel GETs
|
|
204
|
+
* that node-redis auto-pipelines into one batch per target node.
|
|
205
|
+
*
|
|
206
|
+
* Callers that already use hash-tagged keys pay no overhead; cross-slot callers degrade
|
|
207
|
+
* gracefully instead of throwing.
|
|
208
|
+
*/
|
|
209
|
+
declare function mGetImpl(client: TSRedisClient, keys: string[]): Promise<(string | null)[]>;
|
|
210
|
+
/**
|
|
211
|
+
* Topology-aware multi-key SET (pipeline + CROSSSLOT fallback).
|
|
212
|
+
*
|
|
213
|
+
* Fast path: `multi().exec()` pipeline — one round-trip for all keys on the same slot.
|
|
214
|
+
* Cluster CROSSSLOT path: falls back to per-key SETEX/SET via `Promise.all`.
|
|
215
|
+
*
|
|
216
|
+
* entries.value must already be serialised to a string (JSON.stringify beforehand).
|
|
217
|
+
*/
|
|
218
|
+
declare function mSetImpl(client: TSRedisClient, entries: Array<{
|
|
219
|
+
key: string;
|
|
220
|
+
value: string;
|
|
221
|
+
ttl?: number;
|
|
222
|
+
}>): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Topology-aware multi-key DELETE — the single canonical implementation.
|
|
225
|
+
*
|
|
226
|
+
* Standalone / sentinel: single `DEL k1 k2 …` round-trip.
|
|
227
|
+
* Cluster: per-key DEL loop — avoids CROSSSLOT when keys span different hash slots.
|
|
228
|
+
*
|
|
229
|
+
* All callers should use this instead of `client.del(array)` directly.
|
|
230
|
+
*/
|
|
231
|
+
declare function mDelImpl(client: TSRedisClient, keys: string[]): Promise<number>;
|
|
232
|
+
/**
|
|
233
|
+
* Topology-aware FLUSHDB — flushes every data store.
|
|
234
|
+
*
|
|
235
|
+
* Standalone / sentinel: single `flushDb()` call.
|
|
236
|
+
* Cluster: `flushDb()` on the cluster client only flushes the node owning the command's
|
|
237
|
+
* hash slot — i.e. one master. This calls `flushDb()` on every master client directly.
|
|
238
|
+
*
|
|
239
|
+
* Use only in tests and dev tooling — never on production data.
|
|
240
|
+
*/
|
|
241
|
+
declare function flushAllImpl(client: TSRedisClient): Promise<void>;
|
|
242
|
+
declare function closeRedisImpl(): Promise<void>;
|
|
243
|
+
declare function getRedisConnectionStatsImpl(): RedisConnectionStats;
|
|
244
|
+
/**
|
|
245
|
+
* Translate a RedisTopologyDescriptor into the internal RedisConfig shape.
|
|
246
|
+
* Exported as TSRedis.buildConfigFromTopology for callers that need a RedisConfig
|
|
247
|
+
* alongside connectFromTopology (e.g. passing defaultConfig to configureRedisStrategy).
|
|
248
|
+
*/
|
|
249
|
+
declare function buildConfigFromDescriptor(d: RedisTopologyDescriptor): RedisConfig;
|
|
250
|
+
/**
|
|
251
|
+
* Connect using a flat topology descriptor — the preferred entry point for all callers.
|
|
252
|
+
*
|
|
253
|
+
* Handles all three topologies (single / sentinel / cluster) from one call.
|
|
254
|
+
* No environment-variable reads; every value comes explicitly from the descriptor.
|
|
255
|
+
* Idempotent: if a client for this topology is already connected, this is a no-op.
|
|
256
|
+
* Stale closed clients (max-reconnect exhausted) are discarded and reconnected.
|
|
257
|
+
*/
|
|
258
|
+
declare function connectFromTopologyImpl(descriptor: RedisTopologyDescriptor): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Build a RedisTopologyDescriptor from standard Redis environment variables.
|
|
261
|
+
*
|
|
262
|
+
* Detection priority:
|
|
263
|
+
* 1. REDIS_SENTINEL_NODES (comma-separated host:port) → sentinel
|
|
264
|
+
* 2. REDIS_CLUSTER_NODES (comma-separated host:port) → cluster
|
|
265
|
+
* 3. REDIS_URL → single
|
|
266
|
+
* 4. Default → cluster on 127.0.0.1:7000-7005 (local dev default)
|
|
267
|
+
*
|
|
268
|
+
* Env vars consumed:
|
|
269
|
+
* REDIS_SENTINEL_NODES e.g. "127.0.0.1:26380,127.0.0.1:26381,127.0.0.1:26382"
|
|
270
|
+
* REDIS_SENTINEL_MASTER sentinel master name (default: "mymaster")
|
|
271
|
+
* REDIS_CLUSTER_NODES e.g. "127.0.0.1:7000,...,127.0.0.1:7005"
|
|
272
|
+
* REDIS_CLUSTER_HOST_REWRITE host to rewrite cluster-announced addresses to (default: "127.0.0.1")
|
|
273
|
+
* REDIS_URL e.g. "redis://localhost:6379"
|
|
274
|
+
* REDIS_PASSWORD auth password (applied to all modes)
|
|
275
|
+
*
|
|
276
|
+
* For cluster mode the nodeAddressMap handles three redirect scenarios automatically:
|
|
277
|
+
* - Port-matched rewrites (Docker host-port-forward)
|
|
278
|
+
* - k8s FQDN MOVED redirects (redis-cluster-N.* → localhost:startPort+N)
|
|
279
|
+
* - Dynamic Docker pod-IP MOVED redirect mapping
|
|
280
|
+
* When all cluster nodes are non-loopback hosts (direct k8s pod routing), no rewrite is applied.
|
|
281
|
+
*/
|
|
282
|
+
declare function buildTopologyDescriptorFromEnvImpl(): RedisTopologyDescriptor;
|
|
283
|
+
export declare class TSRedis extends EventEmitter {
|
|
284
|
+
redis: TSRedisClient;
|
|
285
|
+
constructor(instance: TSRedisClient);
|
|
286
|
+
/**
|
|
287
|
+
* Connect from a flat topology descriptor — the preferred entry point.
|
|
288
|
+
* Handles single / sentinel / cluster from one call; no env-var reads inside.
|
|
289
|
+
* Idempotent: already-connected clients are reused.
|
|
290
|
+
* Stale closed clients (max-reconnect exhausted) are discarded and reconnected.
|
|
291
|
+
*/
|
|
292
|
+
static connectFromTopology: typeof connectFromTopologyImpl;
|
|
293
|
+
/**
|
|
294
|
+
* Build a RedisTopologyDescriptor from standard Redis env vars.
|
|
295
|
+
* Use with connectFromTopology for zero-config topology-aware connections:
|
|
296
|
+
* await TSRedis.connectFromTopology(TSRedis.buildTopologyDescriptorFromEnv())
|
|
297
|
+
*/
|
|
298
|
+
static buildTopologyDescriptorFromEnv: typeof buildTopologyDescriptorFromEnvImpl;
|
|
299
|
+
/**
|
|
300
|
+
* Translate a RedisTopologyDescriptor into a RedisConfig.
|
|
301
|
+
* Use when another API (e.g. configureRedisStrategy) still takes RedisConfig directly.
|
|
302
|
+
*/
|
|
303
|
+
static buildConfigFromTopology: typeof buildConfigFromDescriptor;
|
|
304
|
+
/** Connect (standalone, Sentinel, Cluster, or with read replicas). Cluster is selected
|
|
305
|
+
* when the supplied `RedisConfig.cluster` is set; otherwise sentinel / standalone per
|
|
306
|
+
* the existing precedence rules. */
|
|
307
|
+
static connect: typeof connectRedisImpl;
|
|
308
|
+
/** Standalone / sentinel client singleton. Returns null in cluster mode — use {@link getCluster}. */
|
|
309
|
+
static getClient: typeof getRedisImpl;
|
|
310
|
+
/** Active cluster client. Returns null when not in cluster mode. */
|
|
311
|
+
static getCluster: typeof getRedisClusterImpl;
|
|
312
|
+
/** Topology-agnostic accessor — returns the active client (standalone / sentinel / cluster). */
|
|
313
|
+
static getActiveClient: typeof getActiveClientImpl;
|
|
314
|
+
static getClientForRead: typeof getRedisForReadImpl;
|
|
315
|
+
static hasReadReplica: typeof hasReadReplicaImpl;
|
|
316
|
+
static close: typeof closeRedisImpl;
|
|
317
|
+
static checkHealth: typeof checkRedisHealthImpl;
|
|
318
|
+
static getConnectionStats: typeof getRedisConnectionStatsImpl;
|
|
319
|
+
static publish: typeof publishImpl;
|
|
320
|
+
static subscribe: typeof subscribeImpl;
|
|
321
|
+
static scanKeysIterator: typeof scanKeysIteratorImpl;
|
|
322
|
+
static batchGetValues: typeof batchGetValuesImpl;
|
|
323
|
+
/**
|
|
324
|
+
* True when `client` is a Redis Cluster client.
|
|
325
|
+
* Prefer the topology-aware helpers (mGet, mSet, mDel, flushAll) over manual branching.
|
|
326
|
+
*/
|
|
327
|
+
static isCluster: typeof isClusterImpl;
|
|
328
|
+
/**
|
|
329
|
+
* Topology-aware MGET: tries a single mGet round-trip; on cluster CROSSSLOT falls back
|
|
330
|
+
* to per-key GETs via Promise.all. Safe for keys that span different hash slots.
|
|
331
|
+
*/
|
|
332
|
+
static mGet: typeof mGetImpl;
|
|
333
|
+
/**
|
|
334
|
+
* Topology-aware multi-key SET: tries a multi().exec() pipeline; on cluster CROSSSLOT
|
|
335
|
+
* falls back to per-key SETEX/SET via Promise.all.
|
|
336
|
+
* entries.value must be pre-serialised (string).
|
|
337
|
+
*/
|
|
338
|
+
static mSet: typeof mSetImpl;
|
|
339
|
+
/**
|
|
340
|
+
* Topology-aware multi-key DELETE: per-key loop in cluster (avoids CROSSSLOT),
|
|
341
|
+
* batch DEL in standalone/sentinel (single round-trip).
|
|
342
|
+
*/
|
|
343
|
+
static mDel: typeof mDelImpl;
|
|
344
|
+
/**
|
|
345
|
+
* Topology-aware FLUSHDB: flushes every master in cluster mode, single flushDb()
|
|
346
|
+
* otherwise. Test/dev tooling only — never call on production data.
|
|
347
|
+
*/
|
|
348
|
+
static flushAll: typeof flushAllImpl;
|
|
349
|
+
cachedRequest(options: Record<string, unknown>, defaultValue?: unknown, debug?: unknown): Promise<any>;
|
|
350
|
+
pathToStore(keys: string[] | undefined, object: unknown): unknown;
|
|
351
|
+
cached: (path: string, options?: {
|
|
352
|
+
value?: string;
|
|
353
|
+
expire?: number;
|
|
354
|
+
}) => Promise<string | undefined>;
|
|
355
|
+
load: (entity: string) => Promise<unknown[]>;
|
|
356
|
+
get: (key: string, cb?: (r: string | null) => unknown) => Promise<unknown>;
|
|
357
|
+
set: (key: string, data: unknown) => Promise<boolean>;
|
|
358
|
+
hget: (key: string, field: string) => Promise<any>;
|
|
359
|
+
getM: (entity: string, keys: string[]) => Promise<(string | null)[]>;
|
|
360
|
+
hgetall: (key: string, cb?: (r: Record<string, string>) => unknown) => Promise<unknown>;
|
|
361
|
+
hset: (key: string, field: string, data: unknown) => Promise<boolean>;
|
|
362
|
+
hdel: (key: string, fields: string[] | string) => Promise<boolean>;
|
|
363
|
+
del: (keys: string[] | string) => Promise<boolean>;
|
|
364
|
+
readonly loadLists: (pattern?: TSRedisPattern) => Promise<Record<string, Record<string, string>>>;
|
|
365
|
+
readonly hscanr: (entity: string, { pattern, COUNT }: TSRedisScan, cb?: TSRedisCallback) => Promise<Record<string, unknown>>;
|
|
366
|
+
readonly zscanr: (entity: string, { pattern, COUNT }: TSRedisScan, cb?: TSRedisCallback) => Promise<unknown[]>;
|
|
367
|
+
readonly scanr: ({ pattern, COUNT }: TSRedisScan, cb?: TSRedisCallback) => Promise<string[]>;
|
|
368
|
+
private static readonly _regexCache;
|
|
369
|
+
private check;
|
|
370
|
+
private match;
|
|
371
|
+
}
|
|
372
|
+
export {};
|