forked from denodrivers/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.ts
946 lines (927 loc) Β· 33.2 KB
/
command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
import type {
Bulk,
BulkNil,
BulkString,
ConditionalArray,
Integer,
Raw,
Status,
} from "./io.ts";
import type { RedisPipeline } from "./pipeline.ts";
import type { RedisSubscription } from "./pubsub.ts";
import type {
StartEndCount,
XAddFieldValues,
XClaimOpts,
XClaimReply,
XId,
XIdAdd,
XIdInput,
XIdNeg,
XIdPos,
XInfoConsumersReply,
XInfoGroupsReply,
XInfoStreamFullReply,
XInfoStreamReply,
XKeyId,
XKeyIdGroup,
XKeyIdGroupLike,
XKeyIdLike,
XMaxlen,
XMessage,
XPendingCount,
XPendingReply,
XReadGroupOpts,
XReadOpts,
XReadReply,
} from "./stream.ts";
export type RedisCommands = {
// Connection
auth(password: string): Promise<Status>;
auth(username: string, password: string): Promise<Status>;
echo(message: string): Promise<BulkString>;
ping(): Promise<Status>;
ping(message: string): Promise<BulkString>;
quit(): Promise<Status>;
select(index: number): Promise<Status>;
// Keys
del(...keys: string[]): Promise<Integer>;
dump(key: string): Promise<Bulk>;
exists(...keys: string[]): Promise<Integer>;
expire(key: string, seconds: number): Promise<Integer>;
expireat(key: string, timestamp: string): Promise<Integer>;
keys(pattern: string): Promise<BulkString[]>;
migrate(
host: string,
port: number | string,
key: string,
destination_db: string,
timeout: number,
opts?: {
copy?: boolean;
replace?: boolean;
auth?: string;
keys?: string[];
},
): Promise<Status>;
move(key: string, db: string): Promise<Integer>;
object_refcount(key: string): Promise<Integer | BulkNil>;
object_encoding(key: string): Promise<Bulk>;
object_idletime(key: string): Promise<Integer | BulkNil>;
object_freq(key: string): Promise<Integer | BulkNil>;
object_help(): Promise<BulkString[]>;
persist(key: string): Promise<Integer>;
pexpire(key: string, milliseconds: number): Promise<Integer>;
pexpireat(key: string, milliseconds_timestamp: number): Promise<Integer>;
pttl(key: string): Promise<Integer>;
randomkey(): Promise<Bulk>;
rename(key: string, newkey: string): Promise<Status>;
renamenx(key: string, newkey: string): Promise<Integer>;
restore(
key: string,
ttl: number,
serialized_value: string,
opts?: {
replace?: boolean;
absttl?: boolean;
idletime?: number;
freq?: number;
},
): Promise<Status>;
scan(
cursor: number,
opts?: { pattern?: string; count?: number; type?: string },
): Promise<[BulkString, BulkString[]]>;
sort(
key: string,
opts?: {
by?: string;
limit?: { offset: number; count: number };
patterns?: string[];
order?: "ASC" | "DESC";
alpha?: boolean;
},
): Promise<BulkString[]>;
sort(
key: string,
opts?: {
by?: string;
limit?: { offset: number; count: number };
patterns?: string[];
order?: "ASC" | "DESC";
alpha?: boolean;
destination: string;
},
): Promise<Integer>;
touch(...keys: string[]): Promise<Integer>;
ttl(key: string): Promise<Integer>;
type(key: string): Promise<Status>;
unlink(...keys: string[]): Promise<Integer>;
wait(numreplicas: number, timeout: number): Promise<Integer>;
// String
append(key: string, value: string): Promise<Integer>;
bitcount(key: string): Promise<Integer>;
bitcount(key: string, start: number, end: number): Promise<Integer>;
bitfield(
key: string,
opts?: {
get?: { type: string; offset: number | string };
set?: { type: string; offset: number | string; value: number };
incrby?: { type: string; offset: number | string; increment: number };
},
): Promise<Integer[]>;
bitfield(
key: string,
opts?: {
get?: { type: string; offset: number | string };
set?: { type: string; offset: number | string; value: number };
incrby?: { type: string; offset: number | string; increment: number };
overflow: "WRAP" | "SAT" | "FAIL";
},
): Promise<(Integer | BulkNil)[]>;
bitop(
operation: "AND" | "OR" | "XOR" | "NOT",
destkey: string,
...keys: string[]
): Promise<Integer>;
bitpos(
key: string,
bit: number,
start?: number,
end?: number,
): Promise<Integer>;
decr(key: string): Promise<Integer>;
decrby(key: string, decrement: number): Promise<Integer>;
get(key: string): Promise<Bulk>;
getbit(key: string, offset: number): Promise<Integer>;
getrange(key: string, start: number, end: number): Promise<BulkString>;
getset(key: string, value: string): Promise<Bulk>;
incr(key: string): Promise<Integer>;
incrby(key: string, increment: number): Promise<Integer>;
incrbyfloat(key: string, increment: number): Promise<BulkString>;
mget(...keys: string[]): Promise<Bulk[]>;
mset(key: string, value: string): Promise<Status>;
mset(...key_values: [string, string][]): Promise<Status>;
mset(key_values: Record<string, string>): Promise<Status>;
msetnx(key: string, value: string): Promise<Integer>;
msetnx(...key_values: [string, string][]): Promise<Integer>;
msetnx(key_values: Record<string, string>): Promise<Integer>;
psetex(key: string, milliseconds: number, value: string): Promise<Status>;
set(
key: string,
value: string,
opts?: { ex?: number; px?: number; keepttl?: boolean },
): Promise<Status>;
set(
key: string,
value: string,
opts?: { ex?: number; px?: number; keepttl?: boolean; mode: "NX" | "XX" },
): Promise<Status | BulkNil>;
setbit(key: string, offset: number, value: string): Promise<Integer>;
setex(key: string, seconds: number, value: string): Promise<Status>;
setnx(key: string, value: string): Promise<Integer>;
setrange(key: string, offset: number, value: string): Promise<Integer>;
stralgo(
algorithm: "LCS",
target: "KEYS" | "STRINGS",
a: string,
b: string,
opts?: {
idx?: boolean;
len?: boolean;
minmatchlen?: number;
withmatchlen?: boolean;
},
): Promise<Bulk>;
strlen(key: string): Promise<Integer>;
// Geo
geoadd(
key: string,
longitude: number,
latitude: number,
member: string,
): Promise<Integer>;
geoadd(
key: string,
...lng_lat_members: [number, number, string][]
): Promise<Integer>;
geoadd(
key: string,
member_lng_lats: Record<string, [number, number]>,
): Promise<Integer>;
geohash(key: string, ...members: string[]): Promise<Bulk[]>;
geopos(
key: string,
...members: string[]
): Promise<([BulkString, BulkString] | BulkNil)[]>;
geodist(
key: string,
member1: string,
member2: string,
unit?: "m" | "km" | "ft" | "mi",
): Promise<Bulk>;
// FIXME: Return type is too conditional
georadius(
key: string,
longitude: number,
latitude: number,
radius: number,
unit: "m" | "km" | "ft" | "mi",
opts?: {
with_coord?: boolean;
with_dist?: boolean;
with_hash?: boolean;
count?: number;
order?: "ASC" | "DESC";
store?: string;
store_dist?: string;
},
): Promise<ConditionalArray>;
// FIXME: Return type is too conditional
georadiusbymember(
key: string,
member: string,
radius: number,
unit: "m" | "km" | "ft" | "mi",
opts?: {
with_coord?: boolean;
with_dist?: boolean;
with_hash?: boolean;
count?: number;
order?: "ASC" | "DESC";
store?: string;
store_dist?: string;
},
): Promise<ConditionalArray>;
// Hash
hdel(key: string, ...fields: string[]): Promise<Integer>;
hexists(key: string, field: string): Promise<Integer>;
hget(key: string, field: string): Promise<Bulk>;
hgetall(key: string): Promise<BulkString[]>;
hincrby(key: string, field: string, increment: number): Promise<Integer>;
hincrbyfloat(
key: string,
field: string,
increment: number,
): Promise<BulkString>;
hkeys(key: string): Promise<BulkString[]>;
hlen(key: string): Promise<Integer>;
hmget(key: string, ...fields: string[]): Promise<Bulk[]>;
/**
* @deprecated since 4.0.0, use hset
*/
hmset(key: string, field: string, value: string): Promise<Status>;
/**
* @deprecated since 4.0.0, use hset
*/
hmset(key: string, ...field_values: [string, string][]): Promise<Status>;
/**
* @deprecated since 4.0.0, use hset
*/
hmset(key: string, field_values: Record<string, string>): Promise<Status>;
hscan(
key: string,
cursor: number,
opts?: { pattern?: string; count?: number },
): Promise<[BulkString, BulkString[]]>;
hset(key: string, field: string, value: string): Promise<Integer>;
hset(key: string, ...field_values: [string, string][]): Promise<Integer>;
hset(key: string, field_values: Record<string, string>): Promise<Integer>;
hsetnx(key: string, field: string, value: string): Promise<Integer>;
hstrlen(key: string, field: string): Promise<Integer>;
hvals(key: string): Promise<BulkString[]>;
// List
blpop(
timeout: number,
...keys: string[]
): Promise<[BulkString, BulkString] | []>;
brpop(
timeout: number,
...keys: string[]
): Promise<[BulkString, BulkString] | []>;
brpoplpush(
source: string,
destination: string,
timeout: number,
): Promise<Bulk>;
lindex(key: string, index: number): Promise<Bulk>;
linsert(
key: string,
loc: "BEFORE" | "AFTER",
pivot: string,
value: string,
): Promise<Integer>;
llen(key: string): Promise<Integer>;
lpop(key: string): Promise<Bulk>;
lpush(key: string, ...elements: string[]): Promise<Integer>;
lpushx(key: string, ...elements: string[]): Promise<Integer>;
lrange(key: string, start: number, stop: number): Promise<BulkString[]>;
lrem(key: string, count: number, element: string): Promise<Integer>;
lset(key: string, index: number, element: string): Promise<Status>;
ltrim(key: string, start: number, stop: number): Promise<Status>;
rpop(key: string): Promise<Bulk>;
rpoplpush(source: string, destination: string): Promise<Bulk>;
rpush(key: string, ...elements: string[]): Promise<Integer>;
rpushx(key: string, ...elements: string[]): Promise<Integer>;
// HyperLogLog
pfadd(key: string, ...elements: string[]): Promise<Integer>;
pfcount(...keys: string[]): Promise<Integer>;
pfmerge(destkey: string, ...sourcekeys: string[]): Promise<Status>;
// PubSub
psubscribe(...patterns: string[]): Promise<RedisSubscription>;
pubsub_channels(pattern?: string): Promise<BulkString[]>;
pubsub_numsub(...channels: string[]): Promise<(BulkString | Integer)[]>;
pubsub_numpat(): Promise<Integer>;
publish(channel: string, message: string): Promise<Integer>;
subscribe(...channels: string[]): Promise<RedisSubscription>;
// Set
sadd(key: string, ...members: string[]): Promise<Integer>;
scard(key: string): Promise<Integer>;
sdiff(...keys: string[]): Promise<BulkString[]>;
sdiffstore(destination: string, ...keys: string[]): Promise<Integer>;
sinter(...keys: string[]): Promise<BulkString[]>;
sinterstore(destination: string, ...keys: string[]): Promise<Integer>;
sismember(key: string, member: string): Promise<Integer>;
smembers(key: string): Promise<BulkString[]>;
smove(source: string, destination: string, member: string): Promise<Integer>;
spop(key: string): Promise<Bulk>;
spop(key: string, count: number): Promise<BulkString[]>;
srandmember(key: string): Promise<Bulk>;
srandmember(key: string, count: number): Promise<BulkString[]>;
srem(key: string, ...members: string[]): Promise<Integer>;
sscan(
key: string,
cursor: number,
opts?: { pattern?: string; count?: number },
): Promise<[BulkString, BulkString[]]>;
sunion(...keys: string[]): Promise<BulkString[]>;
sunionstore(destination: string, ...keys: string[]): Promise<Integer>;
// Stream
/**
* The XACK command removes one or multiple messages
* from the pending entries list (PEL) of a stream
* consumer group. A message is pending, and as such
* stored inside the PEL, when it was delivered to
* some consumer, normally as a side effect of calling
* XREADGROUP, or when a consumer took ownership of a
* message calling XCLAIM. The pending message was
* delivered to some consumer but the server is yet not
* sure it was processed at least once. So new calls
* to XREADGROUP to grab the messages history for a
* consumer (for instance using an XId of 0), will
* return such message. Similarly the pending message
* will be listed by the XPENDING command, that
* inspects the PEL.
*
* Once a consumer successfully processes a message,
* it should call XACK so that such message does not
* get processed again, and as a side effect, the PEL
* entry about this message is also purged, releasing
* memory from the Redis server.
*
* @param key the stream key
* @param group the group name
* @param xids the ids to acknowledge
*/
xack(key: string, group: string, ...xids: XIdInput[]): Promise<Integer>;
/**
* Write a message to a stream.
*
* Returns bulk string reply, specifically:
* The command returns the XId of the added entry.
* The XId is the one auto-generated if * is passed
* as XId argument, otherwise the command just returns
* the same XId specified by the user during insertion.
* @param key write to this stream
* @param xid the XId of the entity written to the stream
* @param field_values record object or map of field value pairs
*/
xadd(
key: string,
xid: XIdAdd,
field_values: XAddFieldValues,
): Promise<XId>;
/**
* Write a message to a stream.
*
* Returns bulk string reply, specifically:
* The command returns the XId of the added entry.
* The XId is the one auto-generated if * is passed
* as XId argument, otherwise the command just returns
* the same XId specified by the user during insertion.
* @param key write to this stream
* @param xid the XId of the entity written to the stream
* @param field_values record object or map of field value pairs
* @param maxlen number of elements, and whether or not to use an approximate comparison
*/
xadd(
key: string,
xid: XIdAdd,
field_values: XAddFieldValues,
maxlen: XMaxlen,
): Promise<XId>;
/**
* In the context of a stream consumer group, this command changes the ownership of a pending message, so that the new owner is the
* consumer specified as the command argument.
*
* It returns the claimed messages unless called with the JUSTIDs
* option, in which case it returns only their XIds.
*
* This is a complex command! Read more at https://redis.io/commands/xclaim
*
<pre>
XCLAIM mystream mygroup Alice 3600000 1526569498055-0
1) 1) 1526569498055-0
2) 1) "message"
2) "orange"
</pre>
* @param key the stream name
* @param opts Various arguments for the command. The following are required:
* GROUP: the name of the consumer group which will claim the messages
* CONSUMER: the specific consumer which will claim the message
* MIN-IDLE-TIME: claim messages whose idle time is greater than this number (milliseconds)
*
* The command has multiple options which can be omitted, however
* most are mainly for internal use in order to transfer the
* effects of XCLAIM or other commands to the AOF file and to
* propagate the same effects to the slaves, and are unlikely to
* be useful to normal users:
* IDLE <ms>: Set the idle time (last time it was delivered) of the message. If IDLE is not specified, an IDLE of 0 is assumed, that is, the time count is reset because the message has now a new owner trying to process it.
* TIME <ms-unix-time>: This is the same as IDLE but instead of a relative amount of milliseconds, it sets the idle time to a specific Unix time (in milliseconds). This is useful in order to rewrite the AOF file generating XCLAIM commands.
* RETRYCOUNT <count>: Set the retry counter to the specified value. This counter is incremented every time a message is delivered again. Normally XCLAIM does not alter this counter, which is just served to clients when the XPENDING command is called: this way clients can detect anomalies, like messages that are never processed for some reason after a big number of delivery attempts.
* FORCE: Creates the pending message entry in the PEL even if certain specified XIds are not already in the PEL assigned to a different client. However the message must be exist in the stream, otherwise the XIds of non existing messages are ignored.
* JUSTXID: Return just an array of XIds of messages successfully claimed, without returning the actual message. Using this option means the retry counter is not incremented.
* @param xids the message XIds to claim
*/
xclaim(
key: string,
opts: XClaimOpts,
...xids: XIdInput[]
): Promise<XClaimReply>;
/**
* Removes the specified entries from a stream,
* and returns the number of entries deleted,
* that may be different from the number of
* XIds passed to the command in case certain
* XIds do not exist.
*
* @param key the stream key
* @param xids ids to delete
*/
xdel(key: string, ...xids: XIdInput[]): Promise<Integer>;
/**
* This command is used to create a new consumer group associated
* with a stream.
*
* <pre>
XGROUP CREATE test-man-000 test-group $ MKSTREAM
OK
</pre>
*
* See https://redis.io/commands/xgroup
* @param key stream key
* @param groupName the name of the consumer group
* @param xid The last argument is the XId of the last
* item in the stream to consider already
* delivered. In the above case we used the
* special XId '$' (that means: the XId of the
* last item in the stream). In this case
* the consumers fetching data from that
* consumer group will only see new elements
* arriving in the stream. If instead you
* want consumers to fetch the whole stream
* history, use zero as the starting XId for
* the consumer group
* @param mkstream You can use the optional MKSTREAM subcommand as the last argument after the XId to automatically create the stream, if it doesn't exist. Note that if the stream is created in this way it will have a length of 0.
*/
xgroup_create(
key: string,
groupName: string,
xid: XIdInput | "$",
mkstream?: boolean,
): Promise<Status>;
/**
* Delete a specific consumer from a group, leaving
* the group itself intact.
*
* <pre>
XGROUP DELCONSUMER test-man-000 hellogroup 4
(integer) 0
</pre>
* @param key stream key
* @param groupName the name of the consumer group
* @param consumerName the specific consumer to delete
*/
xgroup_delconsumer(
key: string,
groupName: string,
consumerName: string,
): Promise<Integer>;
/**
* Destroy a consumer group completely. The consumer
* group will be destroyed even if there are active
* consumers and pending messages, so make sure to
* call this command only when really needed.
*
<pre>
XGROUP DESTROY test-man-000 test-group
(integer) 1
</pre>
* @param key stream key
* @param groupName the consumer group to destroy
*/
xgroup_destroy(key: string, groupName: string): Promise<Integer>;
/** A support command which displays text about the
* various subcommands in XGROUP. */
xgroup_help(): Promise<BulkString>;
/**
* Finally it possible to set the next message to deliver
* using the SETID subcommand. Normally the next XId is set
* when the consumer is created, as the last argument of
* XGROUP CREATE. However using this form the next XId can
* be modified later without deleting and creating the
* consumer group again. For instance if you want the
* consumers in a consumer group to re-process all the
* messages in a stream, you may want to set its next ID
* to 0:
<pre>
XGROUP SETID mystream consumer-group-name 0
</pre>
*
* @param key stream key
* @param groupName the consumer group
* @param xid the XId to use for the next message delivered
*/
xgroup_setid(
key: string,
groupName: string,
xid: XIdInput,
): Promise<Status>;
xinfo_stream(key: string): Promise<XInfoStreamReply>;
/**
* returns the entire state of the stream, including entries, groups, consumers and PELs. This form is available since Redis 6.0.
* @param key The stream key
*/
xinfo_stream_full(key: string, count?: number): Promise<XInfoStreamFullReply>;
/**
* Get as output all the consumer groups associated
* with the stream.
*
* @param key the stream key
*/
xinfo_groups(key: string): Promise<XInfoGroupsReply>;
/**
* Get the list of every consumer in a specific
* consumer group.
*
* @param key the stream key
* @param group list consumers for this group
*/
xinfo_consumers(key: string, group: string): Promise<XInfoConsumersReply>;
/**
* Returns the number of entries inside a stream. If the specified key does not exist the command returns zero, as if the stream was empty. However note that unlike other Redis types, zero-length streams are possible, so you should call TYPE or EXISTS in order to check if a key exists or not.
* @param key the stream key to inspect
*/
xlen(key: string): Promise<Integer>;
/** Complex command to obtain info on messages in the Pending Entries List.
*
* Outputs a summary about the pending messages in a given consumer group.
*
* @param key get pending messages on this stream key
* @param group get pending messages for this group
*/
xpending(
key: string,
group: string,
): Promise<XPendingReply>;
/**
* Output more detailed info about pending messages:
*
* - The ID of the message.
* - The name of the consumer that fetched the message and has still to acknowledge it. We call it the current owner of the message.
* - The number of milliseconds that elapsed since the last time this message was delivered to this consumer.
* - The number of times this message was delivered.
*
* If you pass the consumer argument to the command, it will efficiently filter for messages owned by that consumer.
* @param key get pending messages on this stream key
* @param group get pending messages for this group
* @param startEndCount start and end: XId range params. you may specify "-" for start and "+" for end. you must also provide a max count of messages.
* @param consumer optional, filter by this consumer as owner
*/
xpending_count(
key: string,
group: string,
startEndCount: StartEndCount,
consumer?: string,
): Promise<XPendingCount[]>;
/**
* The command returns the stream entries matching a given
* range of XIds. The range is specified by a minimum and
* maximum ID. All the entries having an XId between the
* two specified or exactly one of the two XIds specified
* (closed interval) are returned.
*
* The command also has a reciprocal command returning
* items in the reverse order, called XREVRANGE, which
* is otherwise identical.
*
* The - and + special XIds mean respectively the minimum
* XId possible and the maximum XId possible inside a stream,
* so the following command will just return every
* entry in the stream.
<pre>
XRANGE somestream - +
</pre>
* @param key stream key
* @param start beginning XId, or -
* @param end final XId, or +
* @param count max number of entries to return
*/
xrange(
key: string,
start: XIdNeg,
end: XIdPos,
count?: number,
): Promise<XMessage[]>;
/**
* This command is exactly like XRANGE, but with the
* notable difference of returning the entries in
* reverse order, and also taking the start-end range
* in reverse order: in XREVRANGE you need to state the
* end XId and later the start ID, and the command will
* produce all the element between (or exactly like)
* the two XIds, starting from the end side.
*
* @param key the stream key
* @param start reading backwards, start from this XId. for the maximum, specify "+"
* @param end stop at this XId. for the minimum, specify "-"
* @param count max number of entries to return
*/
xrevrange(
key: string,
start: XIdPos,
end: XIdNeg,
count?: number,
): Promise<XMessage[]>;
/**
* Read data from one or multiple streams, only returning
* entries with an XId greater than the last received XId
* reported by the caller.
* @param key_xids pairs containing the stream key, and
* the XId from which to read
* @param opts optional max count of entries to return
* for each stream, and number of
* milliseconds for which to block
*/
xread(
key_xids: (XKeyId | XKeyIdLike)[],
opts?: XReadOpts,
): Promise<XReadReply>;
/**
* The XREADGROUP command is a special version of the XREAD command with support for consumer groups.
*
* @param key_ids { key, id } pairs to read
* @param opts you must specify group name and consumer name.
* those must be created using the XGROUP command,
* prior to invoking this command. you may optionally
* include a count of records to read, and the number
* of milliseconds to block
*/
xreadgroup(
key_xids: (XKeyIdGroup | XKeyIdGroupLike)[],
opts: XReadGroupOpts,
): Promise<XReadReply>;
/**
* Trims the stream to the indicated number
* of elements.
<pre>XTRIM mystream MAXLEN 1000</pre>
* @param key
* @param maxlen
*/
xtrim(key: string, maxlen: XMaxlen): Promise<Integer>;
// SortedSet
bzpopmin(
timeout: number,
...keys: string[]
): Promise<[BulkString, BulkString, BulkString] | []>;
bzpopmax(
timeout: number,
...keys: string[]
): Promise<[BulkString, BulkString, BulkString] | []>;
zadd(
key: string,
score: number,
member: string,
opts?: { mode?: "NX" | "XX"; ch?: boolean },
): Promise<Integer>;
zadd(
key: string,
score_members: [number, string][],
opts?: { mode?: "NX" | "XX"; ch?: boolean },
): Promise<Integer>;
zadd(
key: string,
member_scores: Record<string, number>,
opts?: { mode?: "NX" | "XX"; ch?: boolean },
): Promise<Integer>;
zadd_incr(
key: string,
score: number,
member: string,
opts?: { mode?: "NX" | "XX"; ch?: boolean },
): Promise<Bulk>;
zcard(key: string): Promise<Integer>;
zcount(key: string, min: number, max: number): Promise<Integer>;
zincrby(key: string, increment: number, member: string): Promise<BulkString>;
zinterstore(
destination: string,
keys: string[],
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
zinterstore(
destination: string,
key_weights: [string, number][],
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
zinterstore(
destination: string,
key_weights: Record<string, number>,
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
zlexcount(key: string, min: string, max: string): Promise<Integer>;
zpopmax(key: string, count?: number): Promise<BulkString[]>;
zpopmin(key: string, count?: number): Promise<BulkString[]>;
zrange(
key: string,
start: number,
stop: number,
opts?: { with_score?: boolean },
): Promise<BulkString[]>;
zrangebylex(
key: string,
min: string,
max: string,
opts?: { limit?: { offset: number; count: number } },
): Promise<BulkString[]>;
zrangebyscore(
key: string,
min: number | string,
max: number | string,
opts?: { with_score?: boolean; limit?: { offset: number; count: number } },
): Promise<BulkString[]>;
zrank(key: string, member: string): Promise<Integer | BulkNil>;
zrem(key: string, ...members: string[]): Promise<Integer>;
zremrangebylex(key: string, min: string, max: string): Promise<Integer>;
zremrangebyrank(key: string, start: number, stop: number): Promise<Integer>;
zremrangebyscore(
key: string,
min: number | string,
max: number | string,
): Promise<Integer>;
zrevrange(
key: string,
start: number,
stop: number,
opts?: { with_score?: boolean },
): Promise<BulkString[]>;
zrevrangebylex(
key: string,
max: string,
min: string,
opts?: { limit?: { offset: number; count: number } },
): Promise<BulkString[]>;
zrevrangebyscore(
key: string,
max: number | string,
min: number | string,
opts?: { with_score?: boolean; limit?: { offset: number; count: number } },
): Promise<BulkString[]>;
zrevrank(key: string, member: string): Promise<Integer | BulkNil>;
zscan(
key: string,
cursor: number,
opts?: { pattern?: string; count?: number },
): Promise<[BulkString, BulkString[]]>;
zscore(key: string, member: string): Promise<Bulk>;
zunionstore(
destination: string,
keys: string[],
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
zunionstore(
destination: string,
key_weights: [string, number][],
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
zunionstore(
destination: string,
key_weights: Record<string, number>,
opts?: { aggregate?: "SUM" | "MIN" | "MAX" },
): Promise<Integer>;
// Cluster
cluster_addslots(...slots: number[]): Promise<Status>;
cluster_countfailurereports(node_id: string): Promise<Integer>;
cluster_countkeysinslot(slot: number): Promise<Integer>;
cluster_delslots(...slots: number[]): Promise<Status>;
cluster_failover(mode?: "FORCE" | "TAKEOVER"): Promise<Status>;
cluster_flushslots(): Promise<Status>;
cluster_forget(node_id: string): Promise<Status>;
cluster_getkeysinslot(slot: number, count: number): Promise<BulkString[]>;
cluster_info(): Promise<BulkString>;
cluster_keyslot(key: string): Promise<Integer>;
cluster_meet(ip: string, port: number): Promise<Status>;
cluster_myid(): Promise<BulkString>;
cluster_nodes(): Promise<BulkString>;
cluster_replicas(node_id: string): Promise<BulkString[]>;
cluster_replicate(node_id: string): Promise<Status>;
cluster_reset(mode?: "HARD" | "SOFT"): Promise<Status>;
cluster_saveconfig(): Promise<Status>;
cluster_setslot(
slot: number,
subcommand: "IMPORTING" | "MIGRATING" | "NODE" | "STABLE",
node_id?: string,
): Promise<Status>;
cluster_slaves(node_id: string): Promise<BulkString[]>;
cluster_slots(): Promise<ConditionalArray>;
readonly(): Promise<Status>;
readwrite(): Promise<Status>;
// Server
acl_cat(categoryname?: string): Promise<BulkString[]>;
acl_deluser(...usernames: string[]): Promise<Integer>;
acl_genpass(bits?: number): Promise<BulkString>;
acl_getuser(username: string): Promise<(BulkString | BulkString[])[]>;
acl_help(): Promise<BulkString[]>;
acl_list(): Promise<BulkString[]>;
acl_load(): Promise<Status>;
acl_log(count: number): Promise<BulkString[]>;
acl_log(mode: "RESET"): Promise<Status>;
acl_save(): Promise<Status>;
acl_setuser(username: string, ...rules: string[]): Promise<Status>;
acl_users(): Promise<BulkString[]>;
acl_whoami(): Promise<BulkString>;
bgrewriteaof(): Promise<Status>;
bgsave(): Promise<Status>;
command(): Promise<
[BulkString, Integer, BulkString[], Integer, Integer, Integer][]
>;
command_count(): Promise<Integer>;
command_getkeys(): Promise<BulkString[]>;
command_info(
...command_names: string[]
): Promise<
([BulkString, Integer, BulkString[], Integer, Integer, Integer] | BulkNil)[]
>;
config_get(parameter: string): Promise<BulkString[]>;
config_resetstat(): Promise<Status>;
config_rewrite(): Promise<Status>;
config_set(parameter: string, value: string): Promise<Status>;
dbsize(): Promise<Integer>;
debug_object(key: string): Promise<Status>;
debug_segfault(): Promise<Status>;
flushall(async?: boolean): Promise<Status>;
flushdb(async?: boolean): Promise<Status>;
info(section?: string): Promise<BulkString>;
lastsave(): Promise<Integer>;
memory_doctor(): Promise<BulkString>;
memory_help(): Promise<BulkString[]>;
memory_malloc_stats(): Promise<BulkString>;
memory_purge(): Promise<Status>;
memory_stats(): Promise<ConditionalArray>;
memory_usage(key: string, opts?: { samples?: number }): Promise<Integer>;
module_list(): Promise<BulkString[]>;
module_load(path: string, ...args: string[]): Promise<Status>;
module_unload(name: string): Promise<Status>;
monitor(): void;
replicaof(host: string, port: number): Promise<Status>;
replicaof_no_one(): Promise<Status>;
role(): Promise<
| ["master", Integer, BulkString[][]]
| ["slave", BulkString, Integer, BulkString, Integer]
| ["sentinel", BulkString[]]
>;
save(): Promise<Status>;
shutdown(mode?: "NOSAVE" | "SAVE"): Promise<Status>;
slaveof(host: string, port: number): Promise<Status>;
slaveof_no_one(): Promise<Status>;
slowlog(subcommand: string, ...args: string[]): Promise<ConditionalArray>;
swapdb(index1: number, index2: number): Promise<Status>;
sync(): void;
time(): Promise<[BulkString, BulkString]>;
// Scripting
eval(script: string, keys: string[], args: string[]): Promise<Raw>;
evalsha(sha1: string, keys: string[], args: string[]): Promise<Raw>;
script_debug(mode: "YES" | "SYNC" | "NO"): Promise<Status>;
script_exists(...sha1s: string[]): Promise<Integer[]>;
script_flush(): Promise<Status>;
script_kill(): Promise<Status>;
script_load(script: string): Promise<Status>;
// Transactions
discard(): Promise<Status>;
exec(): Promise<ConditionalArray>;
multi(): Promise<Status>;
unwatch(): Promise<Status>;
watch(...keys: string[]): Promise<Status>;
// Pipeline
tx(): RedisPipeline;
pipeline(): RedisPipeline;
};