@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.js CHANGED
@@ -5,17 +5,19 @@ function assert(condition, message) {
5
5
  if (!condition)
6
6
  throw new TypeError(message);
7
7
  }
8
- const safeArgs = (arg1, arg2, cb) => {
9
- if (arg2 !== undefined) {
10
- const arg2Type = typeof arg2;
11
- if (arg2Type === 'function') {
12
- cb = arg2;
13
- arg2 = undefined;
14
- }
8
+ /**
9
+ * Normalises the `(options?, cb?)` tail. A caller may pass the callback in the options slot, in
10
+ * which case it is shifted across so the options argument stays a plain value.
11
+ */
12
+ const safeArgs = (options, cb) => {
13
+ if (typeof options === 'function') {
14
+ if (cb === undefined)
15
+ cb = options;
16
+ options = undefined;
15
17
  }
16
18
  if (cb !== undefined)
17
19
  assert(typeof cb === 'function', `Callback expected function, received ${typeof cb}`);
18
- return [arg1, arg2, cb];
20
+ return [options, cb];
19
21
  };
20
22
  const exp = global.exports['redisfx'];
21
23
  const currentResourceName = GetCurrentResourceName();
@@ -48,24 +50,37 @@ exports.redisfx = {
48
50
  return cb ? cb(result) : result;
49
51
  },
50
52
  async set(key, value, options, cb) {
51
- [options, , cb] = safeArgs(options, cb);
53
+ [options, cb] = safeArgs(options, cb);
52
54
  const result = await execute('set', key, value, options);
53
55
  return cb ? cb(result) : result;
54
56
  },
55
- async del(keys, cb) {
56
- const result = await execute('del', keys);
57
+ async getdel(key, cb) {
58
+ const result = await execute('getdel', key);
57
59
  return cb ? cb(result) : result;
58
60
  },
59
- async exists(keys, cb) {
60
- const result = await execute('exists', keys);
61
+ async getex(key, options, cb) {
62
+ [options, cb] = safeArgs(options, cb);
63
+ const result = await execute('getex', key, options);
61
64
  return cb ? cb(result) : result;
62
65
  },
63
- async expire(key, seconds, cb) {
64
- const result = await execute('expire', key, seconds);
66
+ async getrange(key, start, end, cb) {
67
+ const result = await execute('getrange', key, start, end);
65
68
  return cb ? cb(result) : result;
66
69
  },
67
- async ttl(key, cb) {
68
- const result = await execute('ttl', key);
70
+ async setrange(key, offset, value, cb) {
71
+ const result = await execute('setrange', key, offset, value);
72
+ return cb ? cb(result) : result;
73
+ },
74
+ async append(key, value, cb) {
75
+ const result = await execute('append', key, value);
76
+ return cb ? cb(result) : result;
77
+ },
78
+ async strlen(key, cb) {
79
+ const result = await execute('strlen', key);
80
+ return cb ? cb(result) : result;
81
+ },
82
+ async setnx(key, value, cb) {
83
+ const result = await execute('setnx', key, value);
69
84
  return cb ? cb(result) : result;
70
85
  },
71
86
  async incr(key, cb) {
@@ -76,6 +91,10 @@ exports.redisfx = {
76
91
  const result = await execute('incrby', key, increment);
77
92
  return cb ? cb(result) : result;
78
93
  },
94
+ async incrbyfloat(key, increment, cb) {
95
+ const result = await execute('incrbyfloat', key, increment);
96
+ return cb ? cb(result) : result;
97
+ },
79
98
  async decr(key, cb) {
80
99
  const result = await execute('decr', key);
81
100
  return cb ? cb(result) : result;
@@ -92,6 +111,109 @@ exports.redisfx = {
92
111
  const result = await execute('mset', keyValues);
93
112
  return cb ? cb(result) : result;
94
113
  },
114
+ async msetnx(keyValues, cb) {
115
+ const result = await execute('msetnx', keyValues);
116
+ return cb ? cb(result) : result;
117
+ },
118
+ // Key commands
119
+ async del(keys, cb) {
120
+ const result = await execute('del', keys);
121
+ return cb ? cb(result) : result;
122
+ },
123
+ async unlink(keys, cb) {
124
+ const result = await execute('unlink', keys);
125
+ return cb ? cb(result) : result;
126
+ },
127
+ async exists(keys, cb) {
128
+ const result = await execute('exists', keys);
129
+ return cb ? cb(result) : result;
130
+ },
131
+ async touch(keys, cb) {
132
+ const result = await execute('touch', keys);
133
+ return cb ? cb(result) : result;
134
+ },
135
+ async expire(key, seconds, cb) {
136
+ const result = await execute('expire', key, seconds);
137
+ return cb ? cb(result) : result;
138
+ },
139
+ async pexpire(key, milliseconds, cb) {
140
+ const result = await execute('pexpire', key, milliseconds);
141
+ return cb ? cb(result) : result;
142
+ },
143
+ async expireat(key, timestamp, cb) {
144
+ const result = await execute('expireat', key, timestamp);
145
+ return cb ? cb(result) : result;
146
+ },
147
+ async pexpireat(key, timestamp, cb) {
148
+ const result = await execute('pexpireat', key, timestamp);
149
+ return cb ? cb(result) : result;
150
+ },
151
+ async expiretime(key, cb) {
152
+ const result = await execute('expiretime', key);
153
+ return cb ? cb(result) : result;
154
+ },
155
+ async pexpiretime(key, cb) {
156
+ const result = await execute('pexpiretime', key);
157
+ return cb ? cb(result) : result;
158
+ },
159
+ async ttl(key, cb) {
160
+ const result = await execute('ttl', key);
161
+ return cb ? cb(result) : result;
162
+ },
163
+ async pttl(key, cb) {
164
+ const result = await execute('pttl', key);
165
+ return cb ? cb(result) : result;
166
+ },
167
+ async persist(key, cb) {
168
+ const result = await execute('persist', key);
169
+ return cb ? cb(result) : result;
170
+ },
171
+ async type(key, cb) {
172
+ const result = await execute('type', key);
173
+ return cb ? cb(result) : result;
174
+ },
175
+ async rename(key, newKey, cb) {
176
+ const result = await execute('rename', key, newKey);
177
+ return cb ? cb(result) : result;
178
+ },
179
+ async renamenx(key, newKey, cb) {
180
+ const result = await execute('renamenx', key, newKey);
181
+ return cb ? cb(result) : result;
182
+ },
183
+ async randomkey(cb) {
184
+ const result = await execute('randomkey');
185
+ return cb ? cb(result) : result;
186
+ },
187
+ async keys(pattern, cb) {
188
+ const result = await execute('keys', pattern);
189
+ return cb ? cb(result) : result;
190
+ },
191
+ async copy(source, destination, options, cb) {
192
+ [options, cb] = safeArgs(options, cb);
193
+ const result = await execute('copy', source, destination, options);
194
+ return cb ? cb(result) : result;
195
+ },
196
+ async scan(cursor, options, cb) {
197
+ [options, cb] = safeArgs(options, cb);
198
+ const result = await execute('scan', cursor, options);
199
+ return cb ? cb(result) : result;
200
+ },
201
+ async objectEncoding(key, cb) {
202
+ const result = await execute('objectEncoding', key);
203
+ return cb ? cb(result) : result;
204
+ },
205
+ async memoryUsage(key, cb) {
206
+ const result = await execute('memoryUsage', key);
207
+ return cb ? cb(result) : result;
208
+ },
209
+ async dump(key, cb) {
210
+ const result = await execute('dump', key);
211
+ return cb ? cb(result) : result;
212
+ },
213
+ async restore(key, ttl, serialized, cb) {
214
+ const result = await execute('restore', key, ttl, serialized);
215
+ return cb ? cb(result) : result;
216
+ },
95
217
  // Hash commands
96
218
  async hget(key, field, cb) {
97
219
  const result = await execute('hget', key, field);
@@ -101,6 +223,10 @@ exports.redisfx = {
101
223
  const result = await execute('hset', key, field, value);
102
224
  return cb ? cb(result) : result;
103
225
  },
226
+ async hsetnx(key, field, value, cb) {
227
+ const result = await execute('hsetnx', key, field, value);
228
+ return cb ? cb(result) : result;
229
+ },
104
230
  async hmset(key, fieldValues, cb) {
105
231
  const result = await execute('hmset', key, fieldValues);
106
232
  return cb ? cb(result) : result;
@@ -109,6 +235,10 @@ exports.redisfx = {
109
235
  const result = await execute('hgetall', key);
110
236
  return cb ? cb(result) : result;
111
237
  },
238
+ async hmget(key, fields, cb) {
239
+ const result = await execute('hmget', key, fields);
240
+ return cb ? cb(result) : result;
241
+ },
112
242
  async hdel(key, fields, cb) {
113
243
  const result = await execute('hdel', key, fields);
114
244
  return cb ? cb(result) : result;
@@ -117,6 +247,10 @@ exports.redisfx = {
117
247
  const result = await execute('hincrby', key, field, increment);
118
248
  return cb ? cb(result) : result;
119
249
  },
250
+ async hincrbyfloat(key, field, increment, cb) {
251
+ const result = await execute('hincrbyfloat', key, field, increment);
252
+ return cb ? cb(result) : result;
253
+ },
120
254
  async hexists(key, field, cb) {
121
255
  const result = await execute('hexists', key, field);
122
256
  return cb ? cb(result) : result;
@@ -133,6 +267,56 @@ exports.redisfx = {
133
267
  const result = await execute('hlen', key);
134
268
  return cb ? cb(result) : result;
135
269
  },
270
+ async hstrlen(key, field, cb) {
271
+ const result = await execute('hstrlen', key, field);
272
+ return cb ? cb(result) : result;
273
+ },
274
+ async hrandfield(key, cb) {
275
+ const result = await execute('hrandfield', key);
276
+ return cb ? cb(result) : result;
277
+ },
278
+ async hscan(key, cursor, options, cb) {
279
+ [options, cb] = safeArgs(options, cb);
280
+ const result = await execute('hscan', key, cursor, options);
281
+ return cb ? cb(result) : result;
282
+ },
283
+ async hexpire(key, fields, seconds, cb) {
284
+ const result = await execute('hexpire', key, fields, seconds);
285
+ return cb ? cb(result) : result;
286
+ },
287
+ async hpexpire(key, fields, milliseconds, cb) {
288
+ const result = await execute('hpexpire', key, fields, milliseconds);
289
+ return cb ? cb(result) : result;
290
+ },
291
+ async hexpireat(key, fields, timestamp, cb) {
292
+ const result = await execute('hexpireat', key, fields, timestamp);
293
+ return cb ? cb(result) : result;
294
+ },
295
+ async hpexpireat(key, fields, timestamp, cb) {
296
+ const result = await execute('hpexpireat', key, fields, timestamp);
297
+ return cb ? cb(result) : result;
298
+ },
299
+ async httl(key, fields, cb) {
300
+ const result = await execute('httl', key, fields);
301
+ return cb ? cb(result) : result;
302
+ },
303
+ async hpttl(key, fields, cb) {
304
+ const result = await execute('hpttl', key, fields);
305
+ return cb ? cb(result) : result;
306
+ },
307
+ async hpersist(key, fields, cb) {
308
+ const result = await execute('hpersist', key, fields);
309
+ return cb ? cb(result) : result;
310
+ },
311
+ async hgetex(key, fields, options, cb) {
312
+ [options, cb] = safeArgs(options, cb);
313
+ const result = await execute('hgetex', key, fields, options);
314
+ return cb ? cb(result) : result;
315
+ },
316
+ async hgetdel(key, fields, cb) {
317
+ const result = await execute('hgetdel', key, fields);
318
+ return cb ? cb(result) : result;
319
+ },
136
320
  // List commands
137
321
  async lpush(key, values, cb) {
138
322
  const result = await execute('lpush', key, values);
@@ -142,6 +326,14 @@ exports.redisfx = {
142
326
  const result = await execute('rpush', key, values);
143
327
  return cb ? cb(result) : result;
144
328
  },
329
+ async lpushx(key, values, cb) {
330
+ const result = await execute('lpushx', key, values);
331
+ return cb ? cb(result) : result;
332
+ },
333
+ async rpushx(key, values, cb) {
334
+ const result = await execute('rpushx', key, values);
335
+ return cb ? cb(result) : result;
336
+ },
145
337
  async lpop(key, cb) {
146
338
  const result = await execute('lpop', key);
147
339
  return cb ? cb(result) : result;
@@ -170,6 +362,32 @@ exports.redisfx = {
170
362
  const result = await execute('lrem', key, count, value);
171
363
  return cb ? cb(result) : result;
172
364
  },
365
+ async ltrim(key, start, stop, cb) {
366
+ const result = await execute('ltrim', key, start, stop);
367
+ return cb ? cb(result) : result;
368
+ },
369
+ async lpos(key, element, options, cb) {
370
+ [options, cb] = safeArgs(options, cb);
371
+ const result = await execute('lpos', key, element, options);
372
+ return cb ? cb(result) : result;
373
+ },
374
+ async linsert(key, position, pivot, element, cb) {
375
+ const result = await execute('linsert', key, position, pivot, element);
376
+ return cb ? cb(result) : result;
377
+ },
378
+ async lmove(source, destination, from, to, cb) {
379
+ const result = await execute('lmove', source, destination, from, to);
380
+ return cb ? cb(result) : result;
381
+ },
382
+ async rpoplpush(source, destination, cb) {
383
+ const result = await execute('rpoplpush', source, destination);
384
+ return cb ? cb(result) : result;
385
+ },
386
+ async lmpop(keys, side, options, cb) {
387
+ [options, cb] = safeArgs(options, cb);
388
+ const result = await execute('lmpop', keys, side, options);
389
+ return cb ? cb(result) : result;
390
+ },
173
391
  // Set commands
174
392
  async sadd(key, members, cb) {
175
393
  const result = await execute('sadd', key, members);
@@ -187,6 +405,10 @@ exports.redisfx = {
187
405
  const result = await execute('sismember', key, member);
188
406
  return cb ? cb(result) : result;
189
407
  },
408
+ async smismember(key, members, cb) {
409
+ const result = await execute('smismember', key, members);
410
+ return cb ? cb(result) : result;
411
+ },
190
412
  async scard(key, cb) {
191
413
  const result = await execute('scard', key);
192
414
  return cb ? cb(result) : result;
@@ -195,14 +417,52 @@ exports.redisfx = {
195
417
  const result = await execute('spop', key);
196
418
  return cb ? cb(result) : result;
197
419
  },
420
+ async smove(source, destination, member, cb) {
421
+ const result = await execute('smove', source, destination, member);
422
+ return cb ? cb(result) : result;
423
+ },
198
424
  async srandmember(key, count, cb) {
199
- [count, , cb] = safeArgs(count, cb);
200
- const result = count !== undefined ? await execute('srandmember', key, count) : await execute('srandmember', key);
425
+ [count, cb] = safeArgs(count, cb);
426
+ const result = await execute('srandmember', key, count);
427
+ return cb ? cb(result) : result;
428
+ },
429
+ async sinter(keys, cb) {
430
+ const result = await execute('sinter', keys);
431
+ return cb ? cb(result) : result;
432
+ },
433
+ async sunion(keys, cb) {
434
+ const result = await execute('sunion', keys);
435
+ return cb ? cb(result) : result;
436
+ },
437
+ async sdiff(keys, cb) {
438
+ const result = await execute('sdiff', keys);
439
+ return cb ? cb(result) : result;
440
+ },
441
+ async sintercard(keys, options, cb) {
442
+ [options, cb] = safeArgs(options, cb);
443
+ const result = await execute('sintercard', keys, options);
444
+ return cb ? cb(result) : result;
445
+ },
446
+ async sinterstore(destination, keys, cb) {
447
+ const result = await execute('sinterstore', destination, keys);
448
+ return cb ? cb(result) : result;
449
+ },
450
+ async sunionstore(destination, keys, cb) {
451
+ const result = await execute('sunionstore', destination, keys);
452
+ return cb ? cb(result) : result;
453
+ },
454
+ async sdiffstore(destination, keys, cb) {
455
+ const result = await execute('sdiffstore', destination, keys);
456
+ return cb ? cb(result) : result;
457
+ },
458
+ async sscan(key, cursor, options, cb) {
459
+ [options, cb] = safeArgs(options, cb);
460
+ const result = await execute('sscan', key, cursor, options);
201
461
  return cb ? cb(result) : result;
202
462
  },
203
463
  // Sorted set commands
204
464
  async zadd(key, score, member, options, cb) {
205
- [options, , cb] = safeArgs(options, cb);
465
+ [options, cb] = safeArgs(options, cb);
206
466
  const result = await execute('zadd', key, score, member, options);
207
467
  return cb ? cb(result) : result;
208
468
  },
@@ -214,6 +474,14 @@ exports.redisfx = {
214
474
  const result = await execute('zrangeWithScores', key, start, stop);
215
475
  return cb ? cb(result) : result;
216
476
  },
477
+ async zrangebyscore(key, min, max, cb) {
478
+ const result = await execute('zrangebyscore', key, min, max);
479
+ return cb ? cb(result) : result;
480
+ },
481
+ async zrangestore(destination, source, min, max, cb) {
482
+ const result = await execute('zrangestore', destination, source, min, max);
483
+ return cb ? cb(result) : result;
484
+ },
217
485
  async zrem(key, members, cb) {
218
486
  const result = await execute('zrem', key, members);
219
487
  return cb ? cb(result) : result;
@@ -222,69 +490,227 @@ exports.redisfx = {
222
490
  const result = await execute('zscore', key, member);
223
491
  return cb ? cb(result) : result;
224
492
  },
493
+ async zmscore(key, members, cb) {
494
+ const result = await execute('zmscore', key, members);
495
+ return cb ? cb(result) : result;
496
+ },
225
497
  async zrank(key, member, cb) {
226
498
  const result = await execute('zrank', key, member);
227
499
  return cb ? cb(result) : result;
228
500
  },
501
+ async zrevrank(key, member, cb) {
502
+ const result = await execute('zrevrank', key, member);
503
+ return cb ? cb(result) : result;
504
+ },
229
505
  async zcard(key, cb) {
230
506
  const result = await execute('zcard', key);
231
507
  return cb ? cb(result) : result;
232
508
  },
509
+ async zcount(key, min, max, cb) {
510
+ const result = await execute('zcount', key, min, max);
511
+ return cb ? cb(result) : result;
512
+ },
513
+ async zlexcount(key, min, max, cb) {
514
+ const result = await execute('zlexcount', key, min, max);
515
+ return cb ? cb(result) : result;
516
+ },
233
517
  async zincrby(key, increment, member, cb) {
234
518
  const result = await execute('zincrby', key, increment, member);
235
519
  return cb ? cb(result) : result;
236
520
  },
237
- // Transaction
238
- async multi(commands, cb) {
239
- const result = await execute('multi', commands);
521
+ async zpopmin(key, cb) {
522
+ const result = await execute('zpopmin', key);
240
523
  return cb ? cb(result) : result;
241
524
  },
242
- // Key commands
243
- async keys(pattern, cb) {
244
- const result = await execute('keys', pattern);
525
+ async zpopmax(key, cb) {
526
+ const result = await execute('zpopmax', key);
245
527
  return cb ? cb(result) : result;
246
528
  },
247
- async scan(cursor, options, cb) {
248
- [options, , cb] = safeArgs(options, cb);
249
- const result = await execute('scan', cursor, options);
529
+ async zrandmember(key, cb) {
530
+ const result = await execute('zrandmember', key);
250
531
  return cb ? cb(result) : result;
251
532
  },
252
- async type(key, cb) {
253
- const result = await execute('type', key);
533
+ async zdiff(keys, cb) {
534
+ const result = await execute('zdiff', keys);
254
535
  return cb ? cb(result) : result;
255
536
  },
256
- async rename(key, newKey, cb) {
257
- const result = await execute('rename', key, newKey);
537
+ async zinter(keys, cb) {
538
+ const result = await execute('zinter', keys);
258
539
  return cb ? cb(result) : result;
259
540
  },
260
- async persist(key, cb) {
261
- const result = await execute('persist', key);
541
+ async zunion(keys, cb) {
542
+ const result = await execute('zunion', keys);
262
543
  return cb ? cb(result) : result;
263
544
  },
264
- async pttl(key, cb) {
265
- const result = await execute('pttl', key);
545
+ async zintercard(keys, options, cb) {
546
+ [options, cb] = safeArgs(options, cb);
547
+ const result = await execute('zintercard', keys, options);
266
548
  return cb ? cb(result) : result;
267
549
  },
268
- async expireat(key, timestamp, cb) {
269
- const result = await execute('expireat', key, timestamp);
550
+ async zremrangebyrank(key, start, stop, cb) {
551
+ const result = await execute('zremrangebyrank', key, start, stop);
552
+ return cb ? cb(result) : result;
553
+ },
554
+ async zremrangebyscore(key, min, max, cb) {
555
+ const result = await execute('zremrangebyscore', key, min, max);
556
+ return cb ? cb(result) : result;
557
+ },
558
+ async zremrangebylex(key, min, max, cb) {
559
+ const result = await execute('zremrangebylex', key, min, max);
560
+ return cb ? cb(result) : result;
561
+ },
562
+ async zscan(key, cursor, options, cb) {
563
+ [options, cb] = safeArgs(options, cb);
564
+ const result = await execute('zscan', key, cursor, options);
270
565
  return cb ? cb(result) : result;
271
566
  },
272
- // Server commands
567
+ // Bitmap / HyperLogLog
568
+ async setbit(key, offset, value, cb) {
569
+ const result = await execute('setbit', key, offset, value);
570
+ return cb ? cb(result) : result;
571
+ },
572
+ async getbit(key, offset, cb) {
573
+ const result = await execute('getbit', key, offset);
574
+ return cb ? cb(result) : result;
575
+ },
576
+ async bitcount(key, options, cb) {
577
+ [options, cb] = safeArgs(options, cb);
578
+ const result = await execute('bitcount', key, options);
579
+ return cb ? cb(result) : result;
580
+ },
581
+ async bitpos(key, bit, options, cb) {
582
+ [options, cb] = safeArgs(options, cb);
583
+ const result = await execute('bitpos', key, bit, options);
584
+ return cb ? cb(result) : result;
585
+ },
586
+ async bitop(operation, destination, keys, cb) {
587
+ const result = await execute('bitop', operation, destination, keys);
588
+ return cb ? cb(result) : result;
589
+ },
590
+ async pfadd(key, elements, cb) {
591
+ const result = await execute('pfadd', key, elements);
592
+ return cb ? cb(result) : result;
593
+ },
594
+ async pfcount(keys, cb) {
595
+ const result = await execute('pfcount', keys);
596
+ return cb ? cb(result) : result;
597
+ },
598
+ async pfmerge(destination, sources, cb) {
599
+ const result = await execute('pfmerge', destination, sources);
600
+ return cb ? cb(result) : result;
601
+ },
602
+ // Streams
603
+ async xadd(key, id, message, cb) {
604
+ const result = await execute('xadd', key, id, message);
605
+ return cb ? cb(result) : result;
606
+ },
607
+ async xlen(key, cb) {
608
+ const result = await execute('xlen', key);
609
+ return cb ? cb(result) : result;
610
+ },
611
+ async xrange(key, start, end, cb) {
612
+ const result = await execute('xrange', key, start, end);
613
+ return cb ? cb(result) : result;
614
+ },
615
+ async xrevrange(key, end, start, cb) {
616
+ const result = await execute('xrevrange', key, end, start);
617
+ return cb ? cb(result) : result;
618
+ },
619
+ async xdel(key, ids, cb) {
620
+ const result = await execute('xdel', key, ids);
621
+ return cb ? cb(result) : result;
622
+ },
623
+ async xtrim(key, strategy, threshold, cb) {
624
+ const result = await execute('xtrim', key, strategy, threshold);
625
+ return cb ? cb(result) : result;
626
+ },
627
+ async xack(key, group, ids, cb) {
628
+ const result = await execute('xack', key, group, ids);
629
+ return cb ? cb(result) : result;
630
+ },
631
+ // Scripting
632
+ async eval(script, options, cb) {
633
+ [options, cb] = safeArgs(options, cb);
634
+ const result = await execute('eval', script, options);
635
+ return cb ? cb(result) : result;
636
+ },
637
+ async evalsha(sha, options, cb) {
638
+ [options, cb] = safeArgs(options, cb);
639
+ const result = await execute('evalsha', sha, options);
640
+ return cb ? cb(result) : result;
641
+ },
642
+ async scriptLoad(script, cb) {
643
+ const result = await execute('scriptLoad', script);
644
+ return cb ? cb(result) : result;
645
+ },
646
+ async fcall(fn, options, cb) {
647
+ [options, cb] = safeArgs(options, cb);
648
+ const result = await execute('fcall', fn, options);
649
+ return cb ? cb(result) : result;
650
+ },
651
+ async fcallRo(fn, options, cb) {
652
+ [options, cb] = safeArgs(options, cb);
653
+ const result = await execute('fcallRo', fn, options);
654
+ return cb ? cb(result) : result;
655
+ },
656
+ // Pub/Sub
657
+ async publish(channel, message, cb) {
658
+ const result = await execute('publish', channel, message);
659
+ return cb ? cb(result) : result;
660
+ },
661
+ async spublish(channel, message, cb) {
662
+ const result = await execute('spublish', channel, message);
663
+ return cb ? cb(result) : result;
664
+ },
665
+ async subscribe(channels, options, cb) {
666
+ [options, cb] = safeArgs(options, cb);
667
+ const result = await execute('subscribe', channels, options);
668
+ return cb ? cb(result) : result;
669
+ },
670
+ async unsubscribe(channels, options, cb) {
671
+ [options, cb] = safeArgs(options, cb);
672
+ const result = await execute('unsubscribe', channels, options);
673
+ return cb ? cb(result) : result;
674
+ },
675
+ // Transactions
676
+ async multi(commands, cb) {
677
+ const result = await execute('multi', commands);
678
+ return cb ? cb(result) : result;
679
+ },
680
+ // Server
273
681
  async ping(cb) {
274
682
  const result = await execute('ping');
275
683
  return cb ? cb(result) : result;
276
684
  },
277
- async flushdb(cb) {
278
- const result = await execute('flushdb');
685
+ async time(cb) {
686
+ const result = await execute('time');
279
687
  return cb ? cb(result) : result;
280
688
  },
281
689
  async dbsize(cb) {
282
690
  const result = await execute('dbsize');
283
691
  return cb ? cb(result) : result;
284
692
  },
693
+ async flushdb(cb) {
694
+ const result = await execute('flushdb');
695
+ return cb ? cb(result) : result;
696
+ },
697
+ async flushall(cb) {
698
+ const result = await execute('flushall');
699
+ return cb ? cb(result) : result;
700
+ },
701
+ async info(section, cb) {
702
+ [section, cb] = safeArgs(section, cb);
703
+ const result = await execute('info', section);
704
+ return cb ? cb(result) : result;
705
+ },
706
+ async configGet(parameter, cb) {
707
+ const result = await execute('configGet', parameter);
708
+ return cb ? cb(result) : result;
709
+ },
285
710
  // Raw command
286
711
  async raw(command, args, cb) {
287
- const result = await execute('raw', command, args);
712
+ [args, cb] = safeArgs(args, cb);
713
+ const result = await execute('raw', command, args ?? []);
288
714
  return cb ? cb(result) : result;
289
715
  },
290
716
  };