@m3ftwz/redisfx 1.0.0 → 1.1.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.
package/Redis.ts CHANGED
@@ -22,6 +22,25 @@ interface ZAddOptions {
22
22
  interface ScanOptions {
23
23
  MATCH?: string;
24
24
  COUNT?: number;
25
+ TYPE?: string;
26
+ }
27
+
28
+ interface SubscribeOptions {
29
+ /** Treat the channels as glob patterns (PSUBSCRIBE). */
30
+ pattern?: boolean;
31
+ /** Use sharded pub/sub (SSUBSCRIBE, Redis 7.0+). */
32
+ sharded?: boolean;
33
+ }
34
+
35
+ /** Cursor reply shared by SCAN/HSCAN/SSCAN/ZSCAN. */
36
+ interface ScanReply {
37
+ cursor: string;
38
+ keys: string[];
39
+ }
40
+
41
+ interface ScoredMember {
42
+ value: string;
43
+ score: number;
25
44
  }
26
45
 
27
46
  interface RedisFX {
@@ -32,33 +51,110 @@ interface RedisFX {
32
51
 
33
52
  // String commands
34
53
  get: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
35
- set: <T = string | null>(key: string, value: string | number, options?: SetOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
36
- del: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
37
- exists: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
38
- expire: <T = number>(key: string, seconds: number, cb?: Callback<T>) => Promise<T>;
39
- ttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
54
+ set: <T = string | null>(
55
+ key: string,
56
+ value: string | number,
57
+ options?: SetOptions | Callback<T>,
58
+ cb?: Callback<T>,
59
+ ) => Promise<T>;
60
+ getdel: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
61
+ getex: <T = string | null>(key: string, options?: SetOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
62
+ getrange: <T = string>(key: string, start: number, end: number, cb?: Callback<T>) => Promise<T>;
63
+ setrange: <T = number>(key: string, offset: number, value: string, cb?: Callback<T>) => Promise<T>;
64
+ append: <T = number>(key: string, value: string, cb?: Callback<T>) => Promise<T>;
65
+ strlen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
66
+ setnx: <T = boolean>(key: string, value: string | number, cb?: Callback<T>) => Promise<T>;
40
67
  incr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
41
68
  incrby: <T = number>(key: string, increment: number, cb?: Callback<T>) => Promise<T>;
69
+ incrbyfloat: <T = string>(key: string, increment: number, cb?: Callback<T>) => Promise<T>;
42
70
  decr: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
43
71
  decrby: <T = number>(key: string, decrement: number, cb?: Callback<T>) => Promise<T>;
44
72
  mget: <T = (string | null)[]>(keys: string[], cb?: Callback<T>) => Promise<T>;
45
73
  mset: <T = string>(keyValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
74
+ msetnx: <T = boolean>(keyValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
75
+
76
+ // Key commands
77
+ del: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
78
+ unlink: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
79
+ exists: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
80
+ touch: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
81
+ expire: <T = boolean>(key: string, seconds: number, cb?: Callback<T>) => Promise<T>;
82
+ pexpire: <T = boolean>(key: string, milliseconds: number, cb?: Callback<T>) => Promise<T>;
83
+ expireat: <T = boolean>(key: string, timestamp: number, cb?: Callback<T>) => Promise<T>;
84
+ pexpireat: <T = boolean>(key: string, timestamp: number, cb?: Callback<T>) => Promise<T>;
85
+ expiretime: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
86
+ pexpiretime: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
87
+ ttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
88
+ pttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
89
+ persist: <T = boolean>(key: string, cb?: Callback<T>) => Promise<T>;
90
+ type: <T = string>(key: string, cb?: Callback<T>) => Promise<T>;
91
+ rename: <T = string>(key: string, newKey: string, cb?: Callback<T>) => Promise<T>;
92
+ renamenx: <T = boolean>(key: string, newKey: string, cb?: Callback<T>) => Promise<T>;
93
+ randomkey: <T = string | null>(cb?: Callback<T>) => Promise<T>;
94
+ keys: <T = string[]>(pattern: string, cb?: Callback<T>) => Promise<T>;
95
+ copy: <T = boolean>(
96
+ source: string,
97
+ destination: string,
98
+ options?: { DB?: number; REPLACE?: boolean } | Callback<T>,
99
+ cb?: Callback<T>,
100
+ ) => Promise<T>;
101
+ scan: <T = ScanReply>(cursor: string | number, options?: ScanOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
102
+ objectEncoding: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
103
+ memoryUsage: <T = number | null>(key: string, cb?: Callback<T>) => Promise<T>;
104
+ dump: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
105
+ restore: <T = string>(key: string, ttl: number, serialized: string, cb?: Callback<T>) => Promise<T>;
46
106
 
47
107
  // Hash commands
48
108
  hget: <T = string | null>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
49
109
  hset: <T = number>(key: string, field: string, value: string | number, cb?: Callback<T>) => Promise<T>;
110
+ hsetnx: <T = boolean>(key: string, field: string, value: string | number, cb?: Callback<T>) => Promise<T>;
50
111
  hmset: <T = number>(key: string, fieldValues: Record<string, string | number>, cb?: Callback<T>) => Promise<T>;
51
112
  hgetall: <T = Record<string, string>>(key: string, cb?: Callback<T>) => Promise<T>;
113
+ hmget: <T = (string | null)[]>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
52
114
  hdel: <T = number>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
53
115
  hincrby: <T = number>(key: string, field: string, increment: number, cb?: Callback<T>) => Promise<T>;
54
- hexists: <T = number>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
116
+ hincrbyfloat: <T = string>(key: string, field: string, increment: number, cb?: Callback<T>) => Promise<T>;
117
+ hexists: <T = boolean>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
55
118
  hkeys: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
56
119
  hvals: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
57
120
  hlen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
121
+ hstrlen: <T = number>(key: string, field: string, cb?: Callback<T>) => Promise<T>;
122
+ hrandfield: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
123
+ hscan: <T = ScanReply>(
124
+ key: string,
125
+ cursor: string | number,
126
+ options?: ScanOptions | Callback<T>,
127
+ cb?: Callback<T>,
128
+ ) => Promise<T>;
129
+
130
+ // Hash field expiration (Redis 7.4+)
131
+ hexpire: <T = number[]>(key: string, fields: string | string[], seconds: number, cb?: Callback<T>) => Promise<T>;
132
+ hpexpire: <T = number[]>(
133
+ key: string,
134
+ fields: string | string[],
135
+ milliseconds: number,
136
+ cb?: Callback<T>,
137
+ ) => Promise<T>;
138
+ hexpireat: <T = number[]>(key: string, fields: string | string[], timestamp: number, cb?: Callback<T>) => Promise<T>;
139
+ hpexpireat: <T = number[]>(key: string, fields: string | string[], timestamp: number, cb?: Callback<T>) => Promise<T>;
140
+ httl: <T = number[]>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
141
+ hpttl: <T = number[]>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
142
+ hpersist: <T = number[]>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
143
+ /** HGETEX (Redis 8.0+) - read fields and optionally reset their TTL. */
144
+ hgetex: <T = (string | null)[]>(
145
+ key: string,
146
+ fields: string | string[],
147
+ options?: SetOptions | Callback<T>,
148
+ cb?: Callback<T>,
149
+ ) => Promise<T>;
150
+ /** HGETDEL (Redis 8.0+) - read fields and delete them atomically. */
151
+ hgetdel: <T = (string | null)[]>(key: string, fields: string | string[], cb?: Callback<T>) => Promise<T>;
58
152
 
59
153
  // List commands
60
154
  lpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
61
155
  rpush: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
156
+ lpushx: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
157
+ rpushx: <T = number>(key: string, values: string | string[], cb?: Callback<T>) => Promise<T>;
62
158
  lpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
63
159
  rpop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
64
160
  lrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
@@ -66,63 +162,214 @@ interface RedisFX {
66
162
  lindex: <T = string | null>(key: string, index: number, cb?: Callback<T>) => Promise<T>;
67
163
  lset: <T = string>(key: string, index: number, value: string, cb?: Callback<T>) => Promise<T>;
68
164
  lrem: <T = number>(key: string, count: number, value: string, cb?: Callback<T>) => Promise<T>;
165
+ ltrim: <T = string>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
166
+ lpos: <T = number | null>(
167
+ key: string,
168
+ element: string,
169
+ options?: { RANK?: number; COUNT?: number; MAXLEN?: number } | Callback<T>,
170
+ cb?: Callback<T>,
171
+ ) => Promise<T>;
172
+ linsert: <T = number>(
173
+ key: string,
174
+ position: 'BEFORE' | 'AFTER',
175
+ pivot: string,
176
+ element: string,
177
+ cb?: Callback<T>,
178
+ ) => Promise<T>;
179
+ lmove: <T = string | null>(
180
+ source: string,
181
+ destination: string,
182
+ from: 'LEFT' | 'RIGHT',
183
+ to: 'LEFT' | 'RIGHT',
184
+ cb?: Callback<T>,
185
+ ) => Promise<T>;
186
+ rpoplpush: <T = string | null>(source: string, destination: string, cb?: Callback<T>) => Promise<T>;
187
+ lmpop: <T = { key: string; elements: string[] } | null>(
188
+ keys: string | string[],
189
+ side: 'LEFT' | 'RIGHT',
190
+ options?: { COUNT?: number } | Callback<T>,
191
+ cb?: Callback<T>,
192
+ ) => Promise<T>;
69
193
 
70
194
  // Set commands
71
195
  sadd: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
72
196
  srem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
73
197
  smembers: <T = string[]>(key: string, cb?: Callback<T>) => Promise<T>;
74
- sismember: <T = number>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
198
+ sismember: <T = boolean>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
199
+ smismember: <T = boolean[]>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
75
200
  scard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
76
201
  spop: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
77
- srandmember: <T = string | string[] | null>(key: string, count?: number | Callback<T>, cb?: Callback<T>) => Promise<T>;
202
+ smove: <T = boolean>(source: string, destination: string, member: string, cb?: Callback<T>) => Promise<T>;
203
+ srandmember: <T = string | null>(key: string, count?: number | Callback<T>, cb?: Callback<T>) => Promise<T>;
204
+ sinter: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
205
+ sunion: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
206
+ sdiff: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
207
+ sintercard: <T = number>(
208
+ keys: string | string[],
209
+ options?: { LIMIT?: number } | Callback<T>,
210
+ cb?: Callback<T>,
211
+ ) => Promise<T>;
212
+ sinterstore: <T = number>(destination: string, keys: string | string[], cb?: Callback<T>) => Promise<T>;
213
+ sunionstore: <T = number>(destination: string, keys: string | string[], cb?: Callback<T>) => Promise<T>;
214
+ sdiffstore: <T = number>(destination: string, keys: string | string[], cb?: Callback<T>) => Promise<T>;
215
+ sscan: <T = ScanReply>(
216
+ key: string,
217
+ cursor: string | number,
218
+ options?: ScanOptions | Callback<T>,
219
+ cb?: Callback<T>,
220
+ ) => Promise<T>;
78
221
 
79
222
  // Sorted set commands
80
- zadd: <T = number>(key: string, score: number, member: string, options?: ZAddOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
81
- zrange: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
82
- zrangeWithScores: <T = string[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
223
+ zadd: <T = number>(
224
+ key: string,
225
+ score: number,
226
+ member: string,
227
+ options?: ZAddOptions | Callback<T>,
228
+ cb?: Callback<T>,
229
+ ) => Promise<T>;
230
+ zrange: <T = string[]>(key: string, start: number | string, stop: number | string, cb?: Callback<T>) => Promise<T>;
231
+ zrangeWithScores: <T = ScoredMember[]>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
232
+ zrangebyscore: <T = string[]>(
233
+ key: string,
234
+ min: number | string,
235
+ max: number | string,
236
+ cb?: Callback<T>,
237
+ ) => Promise<T>;
238
+ zrangestore: <T = number>(
239
+ destination: string,
240
+ source: string,
241
+ min: number | string,
242
+ max: number | string,
243
+ cb?: Callback<T>,
244
+ ) => Promise<T>;
83
245
  zrem: <T = number>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
84
- zscore: <T = string | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
246
+ zscore: <T = number | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
247
+ zmscore: <T = (number | null)[]>(key: string, members: string | string[], cb?: Callback<T>) => Promise<T>;
85
248
  zrank: <T = number | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
249
+ zrevrank: <T = number | null>(key: string, member: string, cb?: Callback<T>) => Promise<T>;
86
250
  zcard: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
87
- zincrby: <T = string>(key: string, increment: number, member: string, cb?: Callback<T>) => Promise<T>;
251
+ zcount: <T = number>(key: string, min: number | string, max: number | string, cb?: Callback<T>) => Promise<T>;
252
+ zlexcount: <T = number>(key: string, min: string, max: string, cb?: Callback<T>) => Promise<T>;
253
+ zincrby: <T = number>(key: string, increment: number, member: string, cb?: Callback<T>) => Promise<T>;
254
+ zpopmin: <T = ScoredMember | null>(key: string, cb?: Callback<T>) => Promise<T>;
255
+ zpopmax: <T = ScoredMember | null>(key: string, cb?: Callback<T>) => Promise<T>;
256
+ zrandmember: <T = string | null>(key: string, cb?: Callback<T>) => Promise<T>;
257
+ zdiff: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
258
+ zinter: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
259
+ zunion: <T = string[]>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
260
+ zintercard: <T = number>(
261
+ keys: string | string[],
262
+ options?: { LIMIT?: number } | Callback<T>,
263
+ cb?: Callback<T>,
264
+ ) => Promise<T>;
265
+ zremrangebyrank: <T = number>(key: string, start: number, stop: number, cb?: Callback<T>) => Promise<T>;
266
+ zremrangebyscore: <T = number>(
267
+ key: string,
268
+ min: number | string,
269
+ max: number | string,
270
+ cb?: Callback<T>,
271
+ ) => Promise<T>;
272
+ zremrangebylex: <T = number>(key: string, min: string, max: string, cb?: Callback<T>) => Promise<T>;
273
+ zscan: <T = ScanReply>(
274
+ key: string,
275
+ cursor: string | number,
276
+ options?: ScanOptions | Callback<T>,
277
+ cb?: Callback<T>,
278
+ ) => Promise<T>;
88
279
 
89
- // Transaction commands
90
- multi: <T = any[]>(commands: { command: string; args: any[] }[], cb?: Callback<T>) => Promise<T>;
280
+ // Bitmap / HyperLogLog
281
+ setbit: <T = number>(key: string, offset: number, value: 0 | 1, cb?: Callback<T>) => Promise<T>;
282
+ getbit: <T = number>(key: string, offset: number, cb?: Callback<T>) => Promise<T>;
283
+ bitcount: <T = number>(
284
+ key: string,
285
+ options?: { start?: number; end?: number; mode?: 'BYTE' | 'BIT' } | Callback<T>,
286
+ cb?: Callback<T>,
287
+ ) => Promise<T>;
288
+ bitpos: <T = number>(
289
+ key: string,
290
+ bit: 0 | 1,
291
+ options?: Record<string, any> | Callback<T>,
292
+ cb?: Callback<T>,
293
+ ) => Promise<T>;
294
+ bitop: <T = number>(
295
+ operation: 'AND' | 'OR' | 'XOR' | 'NOT',
296
+ destination: string,
297
+ keys: string | string[],
298
+ cb?: Callback<T>,
299
+ ) => Promise<T>;
300
+ pfadd: <T = boolean>(key: string, elements: string | string[], cb?: Callback<T>) => Promise<T>;
301
+ pfcount: <T = number>(keys: string | string[], cb?: Callback<T>) => Promise<T>;
302
+ pfmerge: <T = string>(destination: string, sources: string | string[], cb?: Callback<T>) => Promise<T>;
91
303
 
92
- // Key commands
93
- keys: <T = string[]>(pattern: string, cb?: Callback<T>) => Promise<T>;
94
- scan: <T = [string, string[]]>(cursor: number, options?: ScanOptions | Callback<T>, cb?: Callback<T>) => Promise<T>;
95
- type: <T = string>(key: string, cb?: Callback<T>) => Promise<T>;
96
- rename: <T = string>(key: string, newKey: string, cb?: Callback<T>) => Promise<T>;
97
- persist: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
98
- pttl: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
99
- expireat: <T = number>(key: string, timestamp: number, cb?: Callback<T>) => Promise<T>;
304
+ // Streams
305
+ xadd: <T = string>(key: string, id: string, message: Record<string, string>, cb?: Callback<T>) => Promise<T>;
306
+ xlen: <T = number>(key: string, cb?: Callback<T>) => Promise<T>;
307
+ xrange: <T = any[]>(key: string, start: string, end: string, cb?: Callback<T>) => Promise<T>;
308
+ xrevrange: <T = any[]>(key: string, end: string, start: string, cb?: Callback<T>) => Promise<T>;
309
+ xdel: <T = number>(key: string, ids: string | string[], cb?: Callback<T>) => Promise<T>;
310
+ xtrim: <T = number>(
311
+ key: string,
312
+ strategy: 'MAXLEN' | 'MINID',
313
+ threshold: number | string,
314
+ cb?: Callback<T>,
315
+ ) => Promise<T>;
316
+ xack: <T = number>(key: string, group: string, ids: string | string[], cb?: Callback<T>) => Promise<T>;
317
+
318
+ // Scripting
319
+ eval: <T = any>(script: string, options?: { keys?: string[]; arguments?: string[] }, cb?: Callback<T>) => Promise<T>;
320
+ evalsha: <T = any>(sha: string, options?: { keys?: string[]; arguments?: string[] }, cb?: Callback<T>) => Promise<T>;
321
+ scriptLoad: <T = string>(script: string, cb?: Callback<T>) => Promise<T>;
322
+ fcall: <T = any>(fn: string, options?: { keys?: string[]; arguments?: string[] }, cb?: Callback<T>) => Promise<T>;
323
+ fcallRo: <T = any>(fn: string, options?: { keys?: string[]; arguments?: string[] }, cb?: Callback<T>) => Promise<T>;
324
+
325
+ // Pub/Sub - messages are delivered as the `redisfx:message` server event
326
+ // (channel: string, message: string, mode: 'channel' | 'pattern' | 'sharded').
327
+ publish: <T = number>(channel: string, message: string, cb?: Callback<T>) => Promise<T>;
328
+ spublish: <T = number>(channel: string, message: string, cb?: Callback<T>) => Promise<T>;
329
+ subscribe: <T = true>(
330
+ channels: string | string[],
331
+ options?: SubscribeOptions | Callback<T>,
332
+ cb?: Callback<T>,
333
+ ) => Promise<T>;
334
+ unsubscribe: <T = true>(
335
+ channels: string | string[],
336
+ options?: SubscribeOptions | Callback<T>,
337
+ cb?: Callback<T>,
338
+ ) => Promise<T>;
339
+
340
+ // Transactions
341
+ multi: <T = any[]>(commands: { command: string; args?: any[] }[], cb?: Callback<T>) => Promise<T>;
100
342
 
101
- // Server commands
343
+ // Server
102
344
  ping: <T = string>(cb?: Callback<T>) => Promise<T>;
103
- flushdb: <T = string>(cb?: Callback<T>) => Promise<T>;
345
+ time: <T = any>(cb?: Callback<T>) => Promise<T>;
104
346
  dbsize: <T = number>(cb?: Callback<T>) => Promise<T>;
347
+ flushdb: <T = string>(cb?: Callback<T>) => Promise<T>;
348
+ flushall: <T = string>(cb?: Callback<T>) => Promise<T>;
349
+ info: <T = string>(section?: string, cb?: Callback<T>) => Promise<T>;
350
+ configGet: <T = Record<string, string>>(parameter: string, cb?: Callback<T>) => Promise<T>;
105
351
 
106
352
  // Raw command
107
- raw: <T = any>(command: string, args: any[], cb?: Callback<T>) => Promise<T>;
353
+ raw: <T = any>(command: string, args?: any[], cb?: Callback<T>) => Promise<T>;
108
354
  }
109
355
 
110
356
  function assert(condition: boolean, message: string) {
111
357
  if (!condition) throw new TypeError(message);
112
358
  }
113
359
 
114
- const safeArgs = (arg1: any, arg2?: any, cb?: Function) => {
115
- if (arg2 !== undefined) {
116
- const arg2Type = typeof arg2;
117
- if (arg2Type === 'function') {
118
- cb = arg2;
119
- arg2 = undefined;
120
- }
360
+ /**
361
+ * Normalises the `(options?, cb?)` tail. A caller may pass the callback in the options slot, in
362
+ * which case it is shifted across so the options argument stays a plain value.
363
+ */
364
+ const safeArgs = (options?: any, cb?: Function): [any, Function | undefined] => {
365
+ if (typeof options === 'function') {
366
+ if (cb === undefined) cb = options;
367
+ options = undefined;
121
368
  }
122
369
 
123
370
  if (cb !== undefined) assert(typeof cb === 'function', `Callback expected function, received ${typeof cb}`);
124
371
 
125
- return [arg1, arg2, cb];
372
+ return [options, cb];
126
373
  };
127
374
 
128
375
  declare var global: any;
@@ -138,7 +385,7 @@ function execute(method: string, ...args: any[]) {
138
385
  resolve(result);
139
386
  },
140
387
  currentResourceName,
141
- true
388
+ true,
142
389
  );
143
390
  }) as any;
144
391
  }
@@ -163,24 +410,37 @@ export const redisfx: RedisFX = {
163
410
  return cb ? cb(result) : result;
164
411
  },
165
412
  async set(key, value, options, cb) {
166
- [options, , cb] = safeArgs(options, cb);
413
+ [options, cb] = safeArgs(options, cb) as any;
167
414
  const result = await execute('set', key, value, options);
168
415
  return cb ? cb(result) : result;
169
416
  },
170
- async del(keys, cb) {
171
- const result = await execute('del', keys);
417
+ async getdel(key, cb) {
418
+ const result = await execute('getdel', key);
172
419
  return cb ? cb(result) : result;
173
420
  },
174
- async exists(keys, cb) {
175
- const result = await execute('exists', keys);
421
+ async getex(key, options, cb) {
422
+ [options, cb] = safeArgs(options, cb) as any;
423
+ const result = await execute('getex', key, options);
176
424
  return cb ? cb(result) : result;
177
425
  },
178
- async expire(key, seconds, cb) {
179
- const result = await execute('expire', key, seconds);
426
+ async getrange(key, start, end, cb) {
427
+ const result = await execute('getrange', key, start, end);
180
428
  return cb ? cb(result) : result;
181
429
  },
182
- async ttl(key, cb) {
183
- const result = await execute('ttl', key);
430
+ async setrange(key, offset, value, cb) {
431
+ const result = await execute('setrange', key, offset, value);
432
+ return cb ? cb(result) : result;
433
+ },
434
+ async append(key, value, cb) {
435
+ const result = await execute('append', key, value);
436
+ return cb ? cb(result) : result;
437
+ },
438
+ async strlen(key, cb) {
439
+ const result = await execute('strlen', key);
440
+ return cb ? cb(result) : result;
441
+ },
442
+ async setnx(key, value, cb) {
443
+ const result = await execute('setnx', key, value);
184
444
  return cb ? cb(result) : result;
185
445
  },
186
446
  async incr(key, cb) {
@@ -191,6 +451,10 @@ export const redisfx: RedisFX = {
191
451
  const result = await execute('incrby', key, increment);
192
452
  return cb ? cb(result) : result;
193
453
  },
454
+ async incrbyfloat(key, increment, cb) {
455
+ const result = await execute('incrbyfloat', key, increment);
456
+ return cb ? cb(result) : result;
457
+ },
194
458
  async decr(key, cb) {
195
459
  const result = await execute('decr', key);
196
460
  return cb ? cb(result) : result;
@@ -207,6 +471,110 @@ export const redisfx: RedisFX = {
207
471
  const result = await execute('mset', keyValues);
208
472
  return cb ? cb(result) : result;
209
473
  },
474
+ async msetnx(keyValues, cb) {
475
+ const result = await execute('msetnx', keyValues);
476
+ return cb ? cb(result) : result;
477
+ },
478
+
479
+ // Key commands
480
+ async del(keys, cb) {
481
+ const result = await execute('del', keys);
482
+ return cb ? cb(result) : result;
483
+ },
484
+ async unlink(keys, cb) {
485
+ const result = await execute('unlink', keys);
486
+ return cb ? cb(result) : result;
487
+ },
488
+ async exists(keys, cb) {
489
+ const result = await execute('exists', keys);
490
+ return cb ? cb(result) : result;
491
+ },
492
+ async touch(keys, cb) {
493
+ const result = await execute('touch', keys);
494
+ return cb ? cb(result) : result;
495
+ },
496
+ async expire(key, seconds, cb) {
497
+ const result = await execute('expire', key, seconds);
498
+ return cb ? cb(result) : result;
499
+ },
500
+ async pexpire(key, milliseconds, cb) {
501
+ const result = await execute('pexpire', key, milliseconds);
502
+ return cb ? cb(result) : result;
503
+ },
504
+ async expireat(key, timestamp, cb) {
505
+ const result = await execute('expireat', key, timestamp);
506
+ return cb ? cb(result) : result;
507
+ },
508
+ async pexpireat(key, timestamp, cb) {
509
+ const result = await execute('pexpireat', key, timestamp);
510
+ return cb ? cb(result) : result;
511
+ },
512
+ async expiretime(key, cb) {
513
+ const result = await execute('expiretime', key);
514
+ return cb ? cb(result) : result;
515
+ },
516
+ async pexpiretime(key, cb) {
517
+ const result = await execute('pexpiretime', key);
518
+ return cb ? cb(result) : result;
519
+ },
520
+ async ttl(key, cb) {
521
+ const result = await execute('ttl', key);
522
+ return cb ? cb(result) : result;
523
+ },
524
+ async pttl(key, cb) {
525
+ const result = await execute('pttl', key);
526
+ return cb ? cb(result) : result;
527
+ },
528
+ async persist(key, cb) {
529
+ const result = await execute('persist', key);
530
+ return cb ? cb(result) : result;
531
+ },
532
+ async type(key, cb) {
533
+ const result = await execute('type', key);
534
+ return cb ? cb(result) : result;
535
+ },
536
+ async rename(key, newKey, cb) {
537
+ const result = await execute('rename', key, newKey);
538
+ return cb ? cb(result) : result;
539
+ },
540
+ async renamenx(key, newKey, cb) {
541
+ const result = await execute('renamenx', key, newKey);
542
+ return cb ? cb(result) : result;
543
+ },
544
+ async randomkey(cb) {
545
+ const result = await execute('randomkey');
546
+ return cb ? cb(result) : result;
547
+ },
548
+ async keys(pattern, cb) {
549
+ const result = await execute('keys', pattern);
550
+ return cb ? cb(result) : result;
551
+ },
552
+ async copy(source, destination, options, cb) {
553
+ [options, cb] = safeArgs(options, cb) as any;
554
+ const result = await execute('copy', source, destination, options);
555
+ return cb ? cb(result) : result;
556
+ },
557
+ async scan(cursor, options, cb) {
558
+ [options, cb] = safeArgs(options, cb) as any;
559
+ const result = await execute('scan', cursor, options);
560
+ return cb ? cb(result) : result;
561
+ },
562
+ async objectEncoding(key, cb) {
563
+ const result = await execute('objectEncoding', key);
564
+ return cb ? cb(result) : result;
565
+ },
566
+ async memoryUsage(key, cb) {
567
+ const result = await execute('memoryUsage', key);
568
+ return cb ? cb(result) : result;
569
+ },
570
+ async dump(key, cb) {
571
+ const result = await execute('dump', key);
572
+ return cb ? cb(result) : result;
573
+ },
574
+ async restore(key, ttl, serialized, cb) {
575
+ const result = await execute('restore', key, ttl, serialized);
576
+ return cb ? cb(result) : result;
577
+ },
210
578
 
211
579
  // Hash commands
212
580
  async hget(key, field, cb) {
@@ -217,6 +585,10 @@ export const redisfx: RedisFX = {
217
585
  const result = await execute('hset', key, field, value);
218
586
  return cb ? cb(result) : result;
219
587
  },
588
+ async hsetnx(key, field, value, cb) {
589
+ const result = await execute('hsetnx', key, field, value);
590
+ return cb ? cb(result) : result;
591
+ },
220
592
  async hmset(key, fieldValues, cb) {
221
593
  const result = await execute('hmset', key, fieldValues);
222
594
  return cb ? cb(result) : result;
@@ -225,6 +597,10 @@ export const redisfx: RedisFX = {
225
597
  const result = await execute('hgetall', key);
226
598
  return cb ? cb(result) : result;
227
599
  },
600
+ async hmget(key, fields, cb) {
601
+ const result = await execute('hmget', key, fields);
602
+ return cb ? cb(result) : result;
603
+ },
228
604
  async hdel(key, fields, cb) {
229
605
  const result = await execute('hdel', key, fields);
230
606
  return cb ? cb(result) : result;
@@ -233,6 +609,10 @@ export const redisfx: RedisFX = {
233
609
  const result = await execute('hincrby', key, field, increment);
234
610
  return cb ? cb(result) : result;
235
611
  },
612
+ async hincrbyfloat(key, field, increment, cb) {
613
+ const result = await execute('hincrbyfloat', key, field, increment);
614
+ return cb ? cb(result) : result;
615
+ },
236
616
  async hexists(key, field, cb) {
237
617
  const result = await execute('hexists', key, field);
238
618
  return cb ? cb(result) : result;
@@ -249,6 +629,56 @@ export const redisfx: RedisFX = {
249
629
  const result = await execute('hlen', key);
250
630
  return cb ? cb(result) : result;
251
631
  },
632
+ async hstrlen(key, field, cb) {
633
+ const result = await execute('hstrlen', key, field);
634
+ return cb ? cb(result) : result;
635
+ },
636
+ async hrandfield(key, cb) {
637
+ const result = await execute('hrandfield', key);
638
+ return cb ? cb(result) : result;
639
+ },
640
+ async hscan(key, cursor, options, cb) {
641
+ [options, cb] = safeArgs(options, cb) as any;
642
+ const result = await execute('hscan', key, cursor, options);
643
+ return cb ? cb(result) : result;
644
+ },
645
+ async hexpire(key, fields, seconds, cb) {
646
+ const result = await execute('hexpire', key, fields, seconds);
647
+ return cb ? cb(result) : result;
648
+ },
649
+ async hpexpire(key, fields, milliseconds, cb) {
650
+ const result = await execute('hpexpire', key, fields, milliseconds);
651
+ return cb ? cb(result) : result;
652
+ },
653
+ async hexpireat(key, fields, timestamp, cb) {
654
+ const result = await execute('hexpireat', key, fields, timestamp);
655
+ return cb ? cb(result) : result;
656
+ },
657
+ async hpexpireat(key, fields, timestamp, cb) {
658
+ const result = await execute('hpexpireat', key, fields, timestamp);
659
+ return cb ? cb(result) : result;
660
+ },
661
+ async httl(key, fields, cb) {
662
+ const result = await execute('httl', key, fields);
663
+ return cb ? cb(result) : result;
664
+ },
665
+ async hpttl(key, fields, cb) {
666
+ const result = await execute('hpttl', key, fields);
667
+ return cb ? cb(result) : result;
668
+ },
669
+ async hpersist(key, fields, cb) {
670
+ const result = await execute('hpersist', key, fields);
671
+ return cb ? cb(result) : result;
672
+ },
673
+ async hgetex(key, fields, options, cb) {
674
+ [options, cb] = safeArgs(options, cb) as any;
675
+ const result = await execute('hgetex', key, fields, options);
676
+ return cb ? cb(result) : result;
677
+ },
678
+ async hgetdel(key, fields, cb) {
679
+ const result = await execute('hgetdel', key, fields);
680
+ return cb ? cb(result) : result;
681
+ },
252
682
 
253
683
  // List commands
254
684
  async lpush(key, values, cb) {
@@ -259,6 +689,14 @@ export const redisfx: RedisFX = {
259
689
  const result = await execute('rpush', key, values);
260
690
  return cb ? cb(result) : result;
261
691
  },
692
+ async lpushx(key, values, cb) {
693
+ const result = await execute('lpushx', key, values);
694
+ return cb ? cb(result) : result;
695
+ },
696
+ async rpushx(key, values, cb) {
697
+ const result = await execute('rpushx', key, values);
698
+ return cb ? cb(result) : result;
699
+ },
262
700
  async lpop(key, cb) {
263
701
  const result = await execute('lpop', key);
264
702
  return cb ? cb(result) : result;
@@ -287,6 +725,32 @@ export const redisfx: RedisFX = {
287
725
  const result = await execute('lrem', key, count, value);
288
726
  return cb ? cb(result) : result;
289
727
  },
728
+ async ltrim(key, start, stop, cb) {
729
+ const result = await execute('ltrim', key, start, stop);
730
+ return cb ? cb(result) : result;
731
+ },
732
+ async lpos(key, element, options, cb) {
733
+ [options, cb] = safeArgs(options, cb) as any;
734
+ const result = await execute('lpos', key, element, options);
735
+ return cb ? cb(result) : result;
736
+ },
737
+ async linsert(key, position, pivot, element, cb) {
738
+ const result = await execute('linsert', key, position, pivot, element);
739
+ return cb ? cb(result) : result;
740
+ },
741
+ async lmove(source, destination, from, to, cb) {
742
+ const result = await execute('lmove', source, destination, from, to);
743
+ return cb ? cb(result) : result;
744
+ },
745
+ async rpoplpush(source, destination, cb) {
746
+ const result = await execute('rpoplpush', source, destination);
747
+ return cb ? cb(result) : result;
748
+ },
749
+ async lmpop(keys, side, options, cb) {
750
+ [options, cb] = safeArgs(options, cb) as any;
751
+ const result = await execute('lmpop', keys, side, options);
752
+ return cb ? cb(result) : result;
753
+ },
290
754
 
291
755
  // Set commands
292
756
  async sadd(key, members, cb) {
@@ -305,6 +769,10 @@ export const redisfx: RedisFX = {
305
769
  const result = await execute('sismember', key, member);
306
770
  return cb ? cb(result) : result;
307
771
  },
772
+ async smismember(key, members, cb) {
773
+ const result = await execute('smismember', key, members);
774
+ return cb ? cb(result) : result;
775
+ },
308
776
  async scard(key, cb) {
309
777
  const result = await execute('scard', key);
310
778
  return cb ? cb(result) : result;
@@ -313,15 +781,53 @@ export const redisfx: RedisFX = {
313
781
  const result = await execute('spop', key);
314
782
  return cb ? cb(result) : result;
315
783
  },
784
+ async smove(source, destination, member, cb) {
785
+ const result = await execute('smove', source, destination, member);
786
+ return cb ? cb(result) : result;
787
+ },
316
788
  async srandmember(key, count, cb) {
317
- [count, , cb] = safeArgs(count, cb);
318
- const result = count !== undefined ? await execute('srandmember', key, count) : await execute('srandmember', key);
789
+ [count, cb] = safeArgs(count, cb) as any;
790
+ const result = await execute('srandmember', key, count);
791
+ return cb ? cb(result) : result;
792
+ },
793
+ async sinter(keys, cb) {
794
+ const result = await execute('sinter', keys);
795
+ return cb ? cb(result) : result;
796
+ },
797
+ async sunion(keys, cb) {
798
+ const result = await execute('sunion', keys);
799
+ return cb ? cb(result) : result;
800
+ },
801
+ async sdiff(keys, cb) {
802
+ const result = await execute('sdiff', keys);
803
+ return cb ? cb(result) : result;
804
+ },
805
+ async sintercard(keys, options, cb) {
806
+ [options, cb] = safeArgs(options, cb) as any;
807
+ const result = await execute('sintercard', keys, options);
808
+ return cb ? cb(result) : result;
809
+ },
810
+ async sinterstore(destination, keys, cb) {
811
+ const result = await execute('sinterstore', destination, keys);
812
+ return cb ? cb(result) : result;
813
+ },
814
+ async sunionstore(destination, keys, cb) {
815
+ const result = await execute('sunionstore', destination, keys);
816
+ return cb ? cb(result) : result;
817
+ },
818
+ async sdiffstore(destination, keys, cb) {
819
+ const result = await execute('sdiffstore', destination, keys);
820
+ return cb ? cb(result) : result;
821
+ },
822
+ async sscan(key, cursor, options, cb) {
823
+ [options, cb] = safeArgs(options, cb) as any;
824
+ const result = await execute('sscan', key, cursor, options);
319
825
  return cb ? cb(result) : result;
320
826
  },
321
827
 
322
828
  // Sorted set commands
323
829
  async zadd(key, score, member, options, cb) {
324
- [options, , cb] = safeArgs(options, cb);
830
+ [options, cb] = safeArgs(options, cb) as any;
325
831
  const result = await execute('zadd', key, score, member, options);
326
832
  return cb ? cb(result) : result;
327
833
  },
@@ -333,6 +839,14 @@ export const redisfx: RedisFX = {
333
839
  const result = await execute('zrangeWithScores', key, start, stop);
334
840
  return cb ? cb(result) : result;
335
841
  },
842
+ async zrangebyscore(key, min, max, cb) {
843
+ const result = await execute('zrangebyscore', key, min, max);
844
+ return cb ? cb(result) : result;
845
+ },
846
+ async zrangestore(destination, source, min, max, cb) {
847
+ const result = await execute('zrangestore', destination, source, min, max);
848
+ return cb ? cb(result) : result;
849
+ },
336
850
  async zrem(key, members, cb) {
337
851
  const result = await execute('zrem', key, members);
338
852
  return cb ? cb(result) : result;
@@ -341,73 +855,234 @@ export const redisfx: RedisFX = {
341
855
  const result = await execute('zscore', key, member);
342
856
  return cb ? cb(result) : result;
343
857
  },
858
+ async zmscore(key, members, cb) {
859
+ const result = await execute('zmscore', key, members);
860
+ return cb ? cb(result) : result;
861
+ },
344
862
  async zrank(key, member, cb) {
345
863
  const result = await execute('zrank', key, member);
346
864
  return cb ? cb(result) : result;
347
865
  },
866
+ async zrevrank(key, member, cb) {
867
+ const result = await execute('zrevrank', key, member);
868
+ return cb ? cb(result) : result;
869
+ },
348
870
  async zcard(key, cb) {
349
871
  const result = await execute('zcard', key);
350
872
  return cb ? cb(result) : result;
351
873
  },
874
+ async zcount(key, min, max, cb) {
875
+ const result = await execute('zcount', key, min, max);
876
+ return cb ? cb(result) : result;
877
+ },
878
+ async zlexcount(key, min, max, cb) {
879
+ const result = await execute('zlexcount', key, min, max);
880
+ return cb ? cb(result) : result;
881
+ },
352
882
  async zincrby(key, increment, member, cb) {
353
883
  const result = await execute('zincrby', key, increment, member);
354
884
  return cb ? cb(result) : result;
355
885
  },
886
+ async zpopmin(key, cb) {
887
+ const result = await execute('zpopmin', key);
888
+ return cb ? cb(result) : result;
889
+ },
890
+ async zpopmax(key, cb) {
891
+ const result = await execute('zpopmax', key);
892
+ return cb ? cb(result) : result;
893
+ },
894
+ async zrandmember(key, cb) {
895
+ const result = await execute('zrandmember', key);
896
+ return cb ? cb(result) : result;
897
+ },
898
+ async zdiff(keys, cb) {
899
+ const result = await execute('zdiff', keys);
900
+ return cb ? cb(result) : result;
901
+ },
902
+ async zinter(keys, cb) {
903
+ const result = await execute('zinter', keys);
904
+ return cb ? cb(result) : result;
905
+ },
906
+ async zunion(keys, cb) {
907
+ const result = await execute('zunion', keys);
908
+ return cb ? cb(result) : result;
909
+ },
910
+ async zintercard(keys, options, cb) {
911
+ [options, cb] = safeArgs(options, cb) as any;
912
+ const result = await execute('zintercard', keys, options);
913
+ return cb ? cb(result) : result;
914
+ },
915
+ async zremrangebyrank(key, start, stop, cb) {
916
+ const result = await execute('zremrangebyrank', key, start, stop);
917
+ return cb ? cb(result) : result;
918
+ },
919
+ async zremrangebyscore(key, min, max, cb) {
920
+ const result = await execute('zremrangebyscore', key, min, max);
921
+ return cb ? cb(result) : result;
922
+ },
923
+ async zremrangebylex(key, min, max, cb) {
924
+ const result = await execute('zremrangebylex', key, min, max);
925
+ return cb ? cb(result) : result;
926
+ },
927
+ async zscan(key, cursor, options, cb) {
928
+ [options, cb] = safeArgs(options, cb) as any;
929
+ const result = await execute('zscan', key, cursor, options);
930
+ return cb ? cb(result) : result;
931
+ },
356
932
 
357
- // Transaction
358
- async multi(commands, cb) {
359
- const result = await execute('multi', commands);
933
+ // Bitmap / HyperLogLog
934
+ async setbit(key, offset, value, cb) {
935
+ const result = await execute('setbit', key, offset, value);
936
+ return cb ? cb(result) : result;
937
+ },
938
+ async getbit(key, offset, cb) {
939
+ const result = await execute('getbit', key, offset);
940
+ return cb ? cb(result) : result;
941
+ },
942
+ async bitcount(key, options, cb) {
943
+ [options, cb] = safeArgs(options, cb) as any;
944
+ const result = await execute('bitcount', key, options);
945
+ return cb ? cb(result) : result;
946
+ },
947
+ async bitpos(key, bit, options, cb) {
948
+ [options, cb] = safeArgs(options, cb) as any;
949
+ const result = await execute('bitpos', key, bit, options);
950
+ return cb ? cb(result) : result;
951
+ },
952
+ async bitop(operation, destination, keys, cb) {
953
+ const result = await execute('bitop', operation, destination, keys);
954
+ return cb ? cb(result) : result;
955
+ },
956
+ async pfadd(key, elements, cb) {
957
+ const result = await execute('pfadd', key, elements);
958
+ return cb ? cb(result) : result;
959
+ },
960
+ async pfcount(keys, cb) {
961
+ const result = await execute('pfcount', keys);
962
+ return cb ? cb(result) : result;
963
+ },
964
+ async pfmerge(destination, sources, cb) {
965
+ const result = await execute('pfmerge', destination, sources);
360
966
  return cb ? cb(result) : result;
361
967
  },
362
968
 
363
- // Key commands
364
- async keys(pattern, cb) {
365
- const result = await execute('keys', pattern);
969
+ // Streams
970
+ async xadd(key, id, message, cb) {
971
+ const result = await execute('xadd', key, id, message);
366
972
  return cb ? cb(result) : result;
367
973
  },
368
- async scan(cursor, options, cb) {
369
- [options, , cb] = safeArgs(options, cb);
370
- const result = await execute('scan', cursor, options);
974
+ async xlen(key, cb) {
975
+ const result = await execute('xlen', key);
371
976
  return cb ? cb(result) : result;
372
977
  },
373
- async type(key, cb) {
374
- const result = await execute('type', key);
978
+ async xrange(key, start, end, cb) {
979
+ const result = await execute('xrange', key, start, end);
375
980
  return cb ? cb(result) : result;
376
981
  },
377
- async rename(key, newKey, cb) {
378
- const result = await execute('rename', key, newKey);
982
+ async xrevrange(key, end, start, cb) {
983
+ const result = await execute('xrevrange', key, end, start);
379
984
  return cb ? cb(result) : result;
380
985
  },
381
- async persist(key, cb) {
382
- const result = await execute('persist', key);
986
+ async xdel(key, ids, cb) {
987
+ const result = await execute('xdel', key, ids);
383
988
  return cb ? cb(result) : result;
384
989
  },
385
- async pttl(key, cb) {
386
- const result = await execute('pttl', key);
990
+ async xtrim(key, strategy, threshold, cb) {
991
+ const result = await execute('xtrim', key, strategy, threshold);
387
992
  return cb ? cb(result) : result;
388
993
  },
389
- async expireat(key, timestamp, cb) {
390
- const result = await execute('expireat', key, timestamp);
994
+ async xack(key, group, ids, cb) {
995
+ const result = await execute('xack', key, group, ids);
391
996
  return cb ? cb(result) : result;
392
997
  },
393
998
 
394
- // Server commands
999
+ // Scripting
1000
+ async eval(script, options, cb) {
1001
+ [options, cb] = safeArgs(options, cb) as any;
1002
+ const result = await execute('eval', script, options);
1003
+ return cb ? cb(result) : result;
1004
+ },
1005
+ async evalsha(sha, options, cb) {
1006
+ [options, cb] = safeArgs(options, cb) as any;
1007
+ const result = await execute('evalsha', sha, options);
1008
+ return cb ? cb(result) : result;
1009
+ },
1010
+ async scriptLoad(script, cb) {
1011
+ const result = await execute('scriptLoad', script);
1012
+ return cb ? cb(result) : result;
1013
+ },
1014
+ async fcall(fn, options, cb) {
1015
+ [options, cb] = safeArgs(options, cb) as any;
1016
+ const result = await execute('fcall', fn, options);
1017
+ return cb ? cb(result) : result;
1018
+ },
1019
+ async fcallRo(fn, options, cb) {
1020
+ [options, cb] = safeArgs(options, cb) as any;
1021
+ const result = await execute('fcallRo', fn, options);
1022
+ return cb ? cb(result) : result;
1023
+ },
1024
+
1025
+ // Pub/Sub
1026
+ async publish(channel, message, cb) {
1027
+ const result = await execute('publish', channel, message);
1028
+ return cb ? cb(result) : result;
1029
+ },
1030
+ async spublish(channel, message, cb) {
1031
+ const result = await execute('spublish', channel, message);
1032
+ return cb ? cb(result) : result;
1033
+ },
1034
+ async subscribe(channels, options, cb) {
1035
+ [options, cb] = safeArgs(options, cb) as any;
1036
+ const result = await execute('subscribe', channels, options);
1037
+ return cb ? cb(result) : result;
1038
+ },
1039
+ async unsubscribe(channels, options, cb) {
1040
+ [options, cb] = safeArgs(options, cb) as any;
1041
+ const result = await execute('unsubscribe', channels, options);
1042
+ return cb ? cb(result) : result;
1043
+ },
1044
+
1045
+ // Transactions
1046
+ async multi(commands, cb) {
1047
+ const result = await execute('multi', commands);
1048
+ return cb ? cb(result) : result;
1049
+ },
1050
+
1051
+ // Server
395
1052
  async ping(cb) {
396
1053
  const result = await execute('ping');
397
1054
  return cb ? cb(result) : result;
398
1055
  },
399
- async flushdb(cb) {
400
- const result = await execute('flushdb');
1056
+ async time(cb) {
1057
+ const result = await execute('time');
401
1058
  return cb ? cb(result) : result;
402
1059
  },
403
1060
  async dbsize(cb) {
404
1061
  const result = await execute('dbsize');
405
1062
  return cb ? cb(result) : result;
406
1063
  },
1064
+ async flushdb(cb) {
1065
+ const result = await execute('flushdb');
1066
+ return cb ? cb(result) : result;
1067
+ },
1068
+ async flushall(cb) {
1069
+ const result = await execute('flushall');
1070
+ return cb ? cb(result) : result;
1071
+ },
1072
+ async info(section, cb) {
1073
+ [section, cb] = safeArgs(section, cb) as any;
1074
+ const result = await execute('info', section);
1075
+ return cb ? cb(result) : result;
1076
+ },
1077
+ async configGet(parameter, cb) {
1078
+ const result = await execute('configGet', parameter);
1079
+ return cb ? cb(result) : result;
1080
+ },
407
1081
 
408
1082
  // Raw command
409
1083
  async raw(command, args, cb) {
410
- const result = await execute('raw', command, args);
1084
+ [args, cb] = safeArgs(args, cb) as any;
1085
+ const result = await execute('raw', command, args ?? []);
411
1086
  return cb ? cb(result) : result;
412
1087
  },
413
1088
  };