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