@upstash/redis 1.34.1 → 1.34.3-canary
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/chunk-FC2CKVKB.mjs +3810 -0
- package/cloudflare.js +3924 -1
- package/cloudflare.mjs +95 -1
- package/fastly.js +3897 -1
- package/fastly.mjs +68 -1
- package/nodejs.js +3944 -1
- package/nodejs.mjs +115 -1
- package/package.json +1 -1
- package/chunk-6D54FT2F.mjs +0 -1
- package/chunk-JNBN5IB4.js +0 -1
package/nodejs.js
CHANGED
|
@@ -1 +1,3944 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// platforms/nodejs.ts
|
|
31
|
+
var nodejs_exports = {};
|
|
32
|
+
__export(nodejs_exports, {
|
|
33
|
+
Redis: () => Redis2,
|
|
34
|
+
errors: () => error_exports
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(nodejs_exports);
|
|
37
|
+
|
|
38
|
+
// pkg/error.ts
|
|
39
|
+
var error_exports = {};
|
|
40
|
+
__export(error_exports, {
|
|
41
|
+
UpstashError: () => UpstashError,
|
|
42
|
+
UrlError: () => UrlError
|
|
43
|
+
});
|
|
44
|
+
var UpstashError = class extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = "UpstashError";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var UrlError = class extends Error {
|
|
51
|
+
constructor(url) {
|
|
52
|
+
super(
|
|
53
|
+
`Upstash Redis client was passed an invalid URL. You should pass a URL starting with https. Received: "${url}". `
|
|
54
|
+
);
|
|
55
|
+
this.name = "UrlError";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// pkg/http.ts
|
|
60
|
+
var HttpClient = class {
|
|
61
|
+
baseUrl;
|
|
62
|
+
headers;
|
|
63
|
+
options;
|
|
64
|
+
readYourWrites;
|
|
65
|
+
upstashSyncToken = "";
|
|
66
|
+
hasCredentials;
|
|
67
|
+
retry;
|
|
68
|
+
constructor(config) {
|
|
69
|
+
this.options = {
|
|
70
|
+
backend: config.options?.backend,
|
|
71
|
+
agent: config.agent,
|
|
72
|
+
responseEncoding: config.responseEncoding ?? "base64",
|
|
73
|
+
// default to base64
|
|
74
|
+
cache: config.cache,
|
|
75
|
+
signal: config.signal,
|
|
76
|
+
keepAlive: config.keepAlive ?? true
|
|
77
|
+
};
|
|
78
|
+
this.upstashSyncToken = "";
|
|
79
|
+
this.readYourWrites = config.readYourWrites ?? true;
|
|
80
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
81
|
+
const urlRegex = /^https?:\/\/[^\s#$./?].\S*$/;
|
|
82
|
+
if (this.baseUrl && !urlRegex.test(this.baseUrl)) {
|
|
83
|
+
throw new UrlError(this.baseUrl);
|
|
84
|
+
}
|
|
85
|
+
this.headers = {
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
...config.headers
|
|
88
|
+
};
|
|
89
|
+
this.hasCredentials = Boolean(this.baseUrl && this.headers.authorization.split(" ")[1]);
|
|
90
|
+
if (this.options.responseEncoding === "base64") {
|
|
91
|
+
this.headers["Upstash-Encoding"] = "base64";
|
|
92
|
+
}
|
|
93
|
+
this.retry = typeof config.retry === "boolean" && !config.retry ? {
|
|
94
|
+
attempts: 1,
|
|
95
|
+
backoff: () => 0
|
|
96
|
+
} : {
|
|
97
|
+
attempts: config.retry?.retries ?? 5,
|
|
98
|
+
backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
mergeTelemetry(telemetry) {
|
|
102
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Runtime", telemetry.runtime);
|
|
103
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Platform", telemetry.platform);
|
|
104
|
+
this.headers = merge(this.headers, "Upstash-Telemetry-Sdk", telemetry.sdk);
|
|
105
|
+
}
|
|
106
|
+
async request(req) {
|
|
107
|
+
const requestOptions = {
|
|
108
|
+
//@ts-expect-error this should throw due to bun regression
|
|
109
|
+
cache: this.options.cache,
|
|
110
|
+
method: "POST",
|
|
111
|
+
headers: this.headers,
|
|
112
|
+
body: JSON.stringify(req.body),
|
|
113
|
+
keepalive: this.options.keepAlive,
|
|
114
|
+
agent: this.options.agent,
|
|
115
|
+
signal: this.options.signal,
|
|
116
|
+
/**
|
|
117
|
+
* Fastly specific
|
|
118
|
+
*/
|
|
119
|
+
backend: this.options.backend
|
|
120
|
+
};
|
|
121
|
+
if (!this.hasCredentials) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
"[Upstash Redis] Redis client was initialized without url or token. Failed to execute command."
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (this.readYourWrites) {
|
|
127
|
+
const newHeader = this.upstashSyncToken;
|
|
128
|
+
this.headers["upstash-sync-token"] = newHeader;
|
|
129
|
+
}
|
|
130
|
+
let res = null;
|
|
131
|
+
let error = null;
|
|
132
|
+
for (let i = 0; i <= this.retry.attempts; i++) {
|
|
133
|
+
try {
|
|
134
|
+
res = await fetch([this.baseUrl, ...req.path ?? []].join("/"), requestOptions);
|
|
135
|
+
break;
|
|
136
|
+
} catch (error_) {
|
|
137
|
+
if (this.options.signal?.aborted) {
|
|
138
|
+
const myBlob = new Blob([
|
|
139
|
+
JSON.stringify({ result: this.options.signal.reason ?? "Aborted" })
|
|
140
|
+
]);
|
|
141
|
+
const myOptions = {
|
|
142
|
+
status: 200,
|
|
143
|
+
statusText: this.options.signal.reason ?? "Aborted"
|
|
144
|
+
};
|
|
145
|
+
res = new Response(myBlob, myOptions);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
error = error_;
|
|
149
|
+
await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!res) {
|
|
153
|
+
throw error ?? new Error("Exhausted all retries");
|
|
154
|
+
}
|
|
155
|
+
const body = await res.json();
|
|
156
|
+
if (!res.ok) {
|
|
157
|
+
throw new UpstashError(`${body.error}, command was: ${JSON.stringify(req.body)}`);
|
|
158
|
+
}
|
|
159
|
+
if (this.readYourWrites) {
|
|
160
|
+
const headers = res.headers;
|
|
161
|
+
this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
|
|
162
|
+
}
|
|
163
|
+
if (this.readYourWrites) {
|
|
164
|
+
const headers = res.headers;
|
|
165
|
+
this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
|
|
166
|
+
}
|
|
167
|
+
if (this.options.responseEncoding === "base64") {
|
|
168
|
+
if (Array.isArray(body)) {
|
|
169
|
+
return body.map(({ result: result2, error: error2 }) => ({
|
|
170
|
+
result: decode(result2),
|
|
171
|
+
error: error2
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
const result = decode(body.result);
|
|
175
|
+
return { result, error: body.error };
|
|
176
|
+
}
|
|
177
|
+
return body;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function base64decode(b64) {
|
|
181
|
+
let dec = "";
|
|
182
|
+
try {
|
|
183
|
+
const binString = atob(b64);
|
|
184
|
+
const size = binString.length;
|
|
185
|
+
const bytes = new Uint8Array(size);
|
|
186
|
+
for (let i = 0; i < size; i++) {
|
|
187
|
+
bytes[i] = binString.charCodeAt(i);
|
|
188
|
+
}
|
|
189
|
+
dec = new TextDecoder().decode(bytes);
|
|
190
|
+
} catch {
|
|
191
|
+
dec = b64;
|
|
192
|
+
}
|
|
193
|
+
return dec;
|
|
194
|
+
}
|
|
195
|
+
function decode(raw) {
|
|
196
|
+
let result = void 0;
|
|
197
|
+
switch (typeof raw) {
|
|
198
|
+
case "undefined": {
|
|
199
|
+
return raw;
|
|
200
|
+
}
|
|
201
|
+
case "number": {
|
|
202
|
+
result = raw;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
case "object": {
|
|
206
|
+
if (Array.isArray(raw)) {
|
|
207
|
+
result = raw.map(
|
|
208
|
+
(v) => typeof v === "string" ? base64decode(v) : Array.isArray(v) ? v.map((element) => decode(element)) : v
|
|
209
|
+
);
|
|
210
|
+
} else {
|
|
211
|
+
result = null;
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case "string": {
|
|
216
|
+
result = raw === "OK" ? "OK" : base64decode(raw);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
default: {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
function merge(obj, key, value) {
|
|
226
|
+
if (!value) {
|
|
227
|
+
return obj;
|
|
228
|
+
}
|
|
229
|
+
obj[key] = obj[key] ? [obj[key], value].join(",") : value;
|
|
230
|
+
return obj;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// pkg/auto-pipeline.ts
|
|
234
|
+
function createAutoPipelineProxy(_redis, json) {
|
|
235
|
+
const redis = _redis;
|
|
236
|
+
if (!redis.autoPipelineExecutor) {
|
|
237
|
+
redis.autoPipelineExecutor = new AutoPipelineExecutor(redis);
|
|
238
|
+
}
|
|
239
|
+
return new Proxy(redis, {
|
|
240
|
+
get: (redis2, command) => {
|
|
241
|
+
if (command === "pipelineCounter") {
|
|
242
|
+
return redis2.autoPipelineExecutor.pipelineCounter;
|
|
243
|
+
}
|
|
244
|
+
if (command === "json") {
|
|
245
|
+
return createAutoPipelineProxy(redis2, true);
|
|
246
|
+
}
|
|
247
|
+
const commandInRedisButNotPipeline = command in redis2 && !(command in redis2.autoPipelineExecutor.pipeline);
|
|
248
|
+
if (commandInRedisButNotPipeline) {
|
|
249
|
+
return redis2[command];
|
|
250
|
+
}
|
|
251
|
+
const isFunction = json ? typeof redis2.autoPipelineExecutor.pipeline.json[command] === "function" : typeof redis2.autoPipelineExecutor.pipeline[command] === "function";
|
|
252
|
+
if (isFunction) {
|
|
253
|
+
return (...args) => {
|
|
254
|
+
return redis2.autoPipelineExecutor.withAutoPipeline((pipeline) => {
|
|
255
|
+
if (json) {
|
|
256
|
+
pipeline.json[command](
|
|
257
|
+
...args
|
|
258
|
+
);
|
|
259
|
+
} else {
|
|
260
|
+
pipeline[command](...args);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return redis2.autoPipelineExecutor.pipeline[command];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
var AutoPipelineExecutor = class {
|
|
270
|
+
pipelinePromises = /* @__PURE__ */ new WeakMap();
|
|
271
|
+
activePipeline = null;
|
|
272
|
+
indexInCurrentPipeline = 0;
|
|
273
|
+
redis;
|
|
274
|
+
pipeline;
|
|
275
|
+
// only to make sure that proxy can work
|
|
276
|
+
pipelineCounter = 0;
|
|
277
|
+
// to keep track of how many times a pipeline was executed
|
|
278
|
+
constructor(redis) {
|
|
279
|
+
this.redis = redis;
|
|
280
|
+
this.pipeline = redis.pipeline();
|
|
281
|
+
}
|
|
282
|
+
async withAutoPipeline(executeWithPipeline) {
|
|
283
|
+
const pipeline = this.activePipeline ?? this.redis.pipeline();
|
|
284
|
+
if (!this.activePipeline) {
|
|
285
|
+
this.activePipeline = pipeline;
|
|
286
|
+
this.indexInCurrentPipeline = 0;
|
|
287
|
+
}
|
|
288
|
+
const index = this.indexInCurrentPipeline++;
|
|
289
|
+
executeWithPipeline(pipeline);
|
|
290
|
+
const pipelineDone = this.deferExecution().then(() => {
|
|
291
|
+
if (!this.pipelinePromises.has(pipeline)) {
|
|
292
|
+
const pipelinePromise = pipeline.exec();
|
|
293
|
+
this.pipelineCounter += 1;
|
|
294
|
+
this.pipelinePromises.set(pipeline, pipelinePromise);
|
|
295
|
+
this.activePipeline = null;
|
|
296
|
+
}
|
|
297
|
+
return this.pipelinePromises.get(pipeline);
|
|
298
|
+
});
|
|
299
|
+
const results = await pipelineDone;
|
|
300
|
+
return results[index];
|
|
301
|
+
}
|
|
302
|
+
async deferExecution() {
|
|
303
|
+
await Promise.resolve();
|
|
304
|
+
await Promise.resolve();
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// pkg/util.ts
|
|
309
|
+
function parseRecursive(obj) {
|
|
310
|
+
const parsed = Array.isArray(obj) ? obj.map((o) => {
|
|
311
|
+
try {
|
|
312
|
+
return parseRecursive(o);
|
|
313
|
+
} catch {
|
|
314
|
+
return o;
|
|
315
|
+
}
|
|
316
|
+
}) : JSON.parse(obj);
|
|
317
|
+
if (typeof parsed === "number" && parsed.toString() !== obj) {
|
|
318
|
+
return obj;
|
|
319
|
+
}
|
|
320
|
+
return parsed;
|
|
321
|
+
}
|
|
322
|
+
function parseResponse(result) {
|
|
323
|
+
try {
|
|
324
|
+
return parseRecursive(result);
|
|
325
|
+
} catch {
|
|
326
|
+
return result;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function deserializeScanResponse(result) {
|
|
330
|
+
return [result[0], ...parseResponse(result.slice(1))];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// pkg/commands/command.ts
|
|
334
|
+
var defaultSerializer = (c) => {
|
|
335
|
+
switch (typeof c) {
|
|
336
|
+
case "string":
|
|
337
|
+
case "number":
|
|
338
|
+
case "boolean": {
|
|
339
|
+
return c;
|
|
340
|
+
}
|
|
341
|
+
default: {
|
|
342
|
+
return JSON.stringify(c);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
var Command = class {
|
|
347
|
+
command;
|
|
348
|
+
serialize;
|
|
349
|
+
deserialize;
|
|
350
|
+
/**
|
|
351
|
+
* Create a new command instance.
|
|
352
|
+
*
|
|
353
|
+
* You can define a custom `deserialize` function. By default we try to deserialize as json.
|
|
354
|
+
*/
|
|
355
|
+
constructor(command, opts) {
|
|
356
|
+
this.serialize = defaultSerializer;
|
|
357
|
+
this.deserialize = opts?.automaticDeserialization === void 0 || opts.automaticDeserialization ? opts?.deserialize ?? parseResponse : (x) => x;
|
|
358
|
+
this.command = command.map((c) => this.serialize(c));
|
|
359
|
+
if (opts?.latencyLogging) {
|
|
360
|
+
const originalExec = this.exec.bind(this);
|
|
361
|
+
this.exec = async (client) => {
|
|
362
|
+
const start = performance.now();
|
|
363
|
+
const result = await originalExec(client);
|
|
364
|
+
const end = performance.now();
|
|
365
|
+
const loggerResult = (end - start).toFixed(2);
|
|
366
|
+
console.log(
|
|
367
|
+
`Latency for \x1B[38;2;19;185;39m${this.command[0].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
|
|
368
|
+
);
|
|
369
|
+
return result;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Execute the command using a client.
|
|
375
|
+
*/
|
|
376
|
+
async exec(client) {
|
|
377
|
+
const { result, error } = await client.request({
|
|
378
|
+
body: this.command,
|
|
379
|
+
upstashSyncToken: client.upstashSyncToken
|
|
380
|
+
});
|
|
381
|
+
if (error) {
|
|
382
|
+
throw new UpstashError(error);
|
|
383
|
+
}
|
|
384
|
+
if (result === void 0) {
|
|
385
|
+
throw new TypeError("Request did not return a result");
|
|
386
|
+
}
|
|
387
|
+
return this.deserialize(result);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// pkg/commands/append.ts
|
|
392
|
+
var AppendCommand = class extends Command {
|
|
393
|
+
constructor(cmd, opts) {
|
|
394
|
+
super(["append", ...cmd], opts);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// pkg/commands/bitcount.ts
|
|
399
|
+
var BitCountCommand = class extends Command {
|
|
400
|
+
constructor([key, start, end], opts) {
|
|
401
|
+
const command = ["bitcount", key];
|
|
402
|
+
if (typeof start === "number") {
|
|
403
|
+
command.push(start);
|
|
404
|
+
}
|
|
405
|
+
if (typeof end === "number") {
|
|
406
|
+
command.push(end);
|
|
407
|
+
}
|
|
408
|
+
super(command, opts);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
// pkg/commands/bitfield.ts
|
|
413
|
+
var BitFieldCommand = class {
|
|
414
|
+
constructor(args, client, opts, execOperation = (command) => command.exec(this.client)) {
|
|
415
|
+
this.client = client;
|
|
416
|
+
this.opts = opts;
|
|
417
|
+
this.execOperation = execOperation;
|
|
418
|
+
this.command = ["bitfield", ...args];
|
|
419
|
+
}
|
|
420
|
+
command;
|
|
421
|
+
chain(...args) {
|
|
422
|
+
this.command.push(...args);
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
get(...args) {
|
|
426
|
+
return this.chain("get", ...args);
|
|
427
|
+
}
|
|
428
|
+
set(...args) {
|
|
429
|
+
return this.chain("set", ...args);
|
|
430
|
+
}
|
|
431
|
+
incrby(...args) {
|
|
432
|
+
return this.chain("incrby", ...args);
|
|
433
|
+
}
|
|
434
|
+
overflow(overflow) {
|
|
435
|
+
return this.chain("overflow", overflow);
|
|
436
|
+
}
|
|
437
|
+
exec() {
|
|
438
|
+
const command = new Command(this.command, this.opts);
|
|
439
|
+
return this.execOperation(command);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// pkg/commands/bitop.ts
|
|
444
|
+
var BitOpCommand = class extends Command {
|
|
445
|
+
constructor(cmd, opts) {
|
|
446
|
+
super(["bitop", ...cmd], opts);
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// pkg/commands/bitpos.ts
|
|
451
|
+
var BitPosCommand = class extends Command {
|
|
452
|
+
constructor(cmd, opts) {
|
|
453
|
+
super(["bitpos", ...cmd], opts);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// pkg/commands/copy.ts
|
|
458
|
+
var CopyCommand = class extends Command {
|
|
459
|
+
constructor([key, destinationKey, opts], commandOptions) {
|
|
460
|
+
super(["COPY", key, destinationKey, ...opts?.replace ? ["REPLACE"] : []], {
|
|
461
|
+
...commandOptions,
|
|
462
|
+
deserialize(result) {
|
|
463
|
+
if (result > 0) {
|
|
464
|
+
return "COPIED";
|
|
465
|
+
}
|
|
466
|
+
return "NOT_COPIED";
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// pkg/commands/dbsize.ts
|
|
473
|
+
var DBSizeCommand = class extends Command {
|
|
474
|
+
constructor(opts) {
|
|
475
|
+
super(["dbsize"], opts);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// pkg/commands/decr.ts
|
|
480
|
+
var DecrCommand = class extends Command {
|
|
481
|
+
constructor(cmd, opts) {
|
|
482
|
+
super(["decr", ...cmd], opts);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
// pkg/commands/decrby.ts
|
|
487
|
+
var DecrByCommand = class extends Command {
|
|
488
|
+
constructor(cmd, opts) {
|
|
489
|
+
super(["decrby", ...cmd], opts);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// pkg/commands/del.ts
|
|
494
|
+
var DelCommand = class extends Command {
|
|
495
|
+
constructor(cmd, opts) {
|
|
496
|
+
super(["del", ...cmd], opts);
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// pkg/commands/echo.ts
|
|
501
|
+
var EchoCommand = class extends Command {
|
|
502
|
+
constructor(cmd, opts) {
|
|
503
|
+
super(["echo", ...cmd], opts);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
// pkg/commands/eval.ts
|
|
508
|
+
var EvalCommand = class extends Command {
|
|
509
|
+
constructor([script, keys, args], opts) {
|
|
510
|
+
super(["eval", script, keys.length, ...keys, ...args ?? []], opts);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// pkg/commands/evalsha.ts
|
|
515
|
+
var EvalshaCommand = class extends Command {
|
|
516
|
+
constructor([sha, keys, args], opts) {
|
|
517
|
+
super(["evalsha", sha, keys.length, ...keys, ...args ?? []], opts);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// pkg/commands/exists.ts
|
|
522
|
+
var ExistsCommand = class extends Command {
|
|
523
|
+
constructor(cmd, opts) {
|
|
524
|
+
super(["exists", ...cmd], opts);
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// pkg/commands/expire.ts
|
|
529
|
+
var ExpireCommand = class extends Command {
|
|
530
|
+
constructor(cmd, opts) {
|
|
531
|
+
super(["expire", ...cmd.filter(Boolean)], opts);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
// pkg/commands/expireat.ts
|
|
536
|
+
var ExpireAtCommand = class extends Command {
|
|
537
|
+
constructor(cmd, opts) {
|
|
538
|
+
super(["expireat", ...cmd], opts);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// pkg/commands/flushall.ts
|
|
543
|
+
var FlushAllCommand = class extends Command {
|
|
544
|
+
constructor(args, opts) {
|
|
545
|
+
const command = ["flushall"];
|
|
546
|
+
if (args && args.length > 0 && args[0].async) {
|
|
547
|
+
command.push("async");
|
|
548
|
+
}
|
|
549
|
+
super(command, opts);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// pkg/commands/flushdb.ts
|
|
554
|
+
var FlushDBCommand = class extends Command {
|
|
555
|
+
constructor([opts], cmdOpts) {
|
|
556
|
+
const command = ["flushdb"];
|
|
557
|
+
if (opts?.async) {
|
|
558
|
+
command.push("async");
|
|
559
|
+
}
|
|
560
|
+
super(command, cmdOpts);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
// pkg/commands/geo_add.ts
|
|
565
|
+
var GeoAddCommand = class extends Command {
|
|
566
|
+
constructor([key, arg1, ...arg2], opts) {
|
|
567
|
+
const command = ["geoadd", key];
|
|
568
|
+
if ("nx" in arg1 && arg1.nx) {
|
|
569
|
+
command.push("nx");
|
|
570
|
+
} else if ("xx" in arg1 && arg1.xx) {
|
|
571
|
+
command.push("xx");
|
|
572
|
+
}
|
|
573
|
+
if ("ch" in arg1 && arg1.ch) {
|
|
574
|
+
command.push("ch");
|
|
575
|
+
}
|
|
576
|
+
if ("latitude" in arg1 && arg1.latitude) {
|
|
577
|
+
command.push(arg1.longitude, arg1.latitude, arg1.member);
|
|
578
|
+
}
|
|
579
|
+
command.push(
|
|
580
|
+
...arg2.flatMap(({ latitude, longitude, member }) => [longitude, latitude, member])
|
|
581
|
+
);
|
|
582
|
+
super(command, opts);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
// pkg/commands/geo_dist.ts
|
|
587
|
+
var GeoDistCommand = class extends Command {
|
|
588
|
+
constructor([key, member1, member2, unit = "M"], opts) {
|
|
589
|
+
super(["GEODIST", key, member1, member2, unit], opts);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
// pkg/commands/geo_hash.ts
|
|
594
|
+
var GeoHashCommand = class extends Command {
|
|
595
|
+
constructor(cmd, opts) {
|
|
596
|
+
const [key] = cmd;
|
|
597
|
+
const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
|
|
598
|
+
super(["GEOHASH", key, ...members], opts);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
// pkg/commands/geo_pos.ts
|
|
603
|
+
var GeoPosCommand = class extends Command {
|
|
604
|
+
constructor(cmd, opts) {
|
|
605
|
+
const [key] = cmd;
|
|
606
|
+
const members = Array.isArray(cmd[1]) ? cmd[1] : cmd.slice(1);
|
|
607
|
+
super(["GEOPOS", key, ...members], {
|
|
608
|
+
deserialize: (result) => transform(result),
|
|
609
|
+
...opts
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
function transform(result) {
|
|
614
|
+
const final = [];
|
|
615
|
+
for (const pos of result) {
|
|
616
|
+
if (!pos?.[0] || !pos?.[1]) {
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
final.push({ lng: Number.parseFloat(pos[0]), lat: Number.parseFloat(pos[1]) });
|
|
620
|
+
}
|
|
621
|
+
return final;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// pkg/commands/geo_search.ts
|
|
625
|
+
var GeoSearchCommand = class extends Command {
|
|
626
|
+
constructor([key, centerPoint, shape, order, opts], commandOptions) {
|
|
627
|
+
const command = ["GEOSEARCH", key];
|
|
628
|
+
if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
|
|
629
|
+
command.push(centerPoint.type, centerPoint.member);
|
|
630
|
+
}
|
|
631
|
+
if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
|
|
632
|
+
command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
|
|
633
|
+
}
|
|
634
|
+
if (shape.type === "BYRADIUS" || shape.type === "byradius") {
|
|
635
|
+
command.push(shape.type, shape.radius, shape.radiusType);
|
|
636
|
+
}
|
|
637
|
+
if (shape.type === "BYBOX" || shape.type === "bybox") {
|
|
638
|
+
command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
|
|
639
|
+
}
|
|
640
|
+
command.push(order);
|
|
641
|
+
if (opts?.count) {
|
|
642
|
+
command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
|
|
643
|
+
}
|
|
644
|
+
const transform2 = (result) => {
|
|
645
|
+
if (!opts?.withCoord && !opts?.withDist && !opts?.withHash) {
|
|
646
|
+
return result.map((member) => {
|
|
647
|
+
try {
|
|
648
|
+
return { member: JSON.parse(member) };
|
|
649
|
+
} catch {
|
|
650
|
+
return { member };
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
return result.map((members) => {
|
|
655
|
+
let counter = 1;
|
|
656
|
+
const obj = {};
|
|
657
|
+
try {
|
|
658
|
+
obj.member = JSON.parse(members[0]);
|
|
659
|
+
} catch {
|
|
660
|
+
obj.member = members[0];
|
|
661
|
+
}
|
|
662
|
+
if (opts.withDist) {
|
|
663
|
+
obj.dist = Number.parseFloat(members[counter++]);
|
|
664
|
+
}
|
|
665
|
+
if (opts.withHash) {
|
|
666
|
+
obj.hash = members[counter++].toString();
|
|
667
|
+
}
|
|
668
|
+
if (opts.withCoord) {
|
|
669
|
+
obj.coord = {
|
|
670
|
+
long: Number.parseFloat(members[counter][0]),
|
|
671
|
+
lat: Number.parseFloat(members[counter][1])
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
return obj;
|
|
675
|
+
});
|
|
676
|
+
};
|
|
677
|
+
super(
|
|
678
|
+
[
|
|
679
|
+
...command,
|
|
680
|
+
...opts?.withCoord ? ["WITHCOORD"] : [],
|
|
681
|
+
...opts?.withDist ? ["WITHDIST"] : [],
|
|
682
|
+
...opts?.withHash ? ["WITHHASH"] : []
|
|
683
|
+
],
|
|
684
|
+
{
|
|
685
|
+
deserialize: transform2,
|
|
686
|
+
...commandOptions
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
// pkg/commands/geo_search_store.ts
|
|
693
|
+
var GeoSearchStoreCommand = class extends Command {
|
|
694
|
+
constructor([destination, key, centerPoint, shape, order, opts], commandOptions) {
|
|
695
|
+
const command = ["GEOSEARCHSTORE", destination, key];
|
|
696
|
+
if (centerPoint.type === "FROMMEMBER" || centerPoint.type === "frommember") {
|
|
697
|
+
command.push(centerPoint.type, centerPoint.member);
|
|
698
|
+
}
|
|
699
|
+
if (centerPoint.type === "FROMLONLAT" || centerPoint.type === "fromlonlat") {
|
|
700
|
+
command.push(centerPoint.type, centerPoint.coordinate.lon, centerPoint.coordinate.lat);
|
|
701
|
+
}
|
|
702
|
+
if (shape.type === "BYRADIUS" || shape.type === "byradius") {
|
|
703
|
+
command.push(shape.type, shape.radius, shape.radiusType);
|
|
704
|
+
}
|
|
705
|
+
if (shape.type === "BYBOX" || shape.type === "bybox") {
|
|
706
|
+
command.push(shape.type, shape.rect.width, shape.rect.height, shape.rectType);
|
|
707
|
+
}
|
|
708
|
+
command.push(order);
|
|
709
|
+
if (opts?.count) {
|
|
710
|
+
command.push("COUNT", opts.count.limit, ...opts.count.any ? ["ANY"] : []);
|
|
711
|
+
}
|
|
712
|
+
super([...command, ...opts?.storeDist ? ["STOREDIST"] : []], commandOptions);
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// pkg/commands/get.ts
|
|
717
|
+
var GetCommand = class extends Command {
|
|
718
|
+
constructor(cmd, opts) {
|
|
719
|
+
super(["get", ...cmd], opts);
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
// pkg/commands/getbit.ts
|
|
724
|
+
var GetBitCommand = class extends Command {
|
|
725
|
+
constructor(cmd, opts) {
|
|
726
|
+
super(["getbit", ...cmd], opts);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// pkg/commands/getdel.ts
|
|
731
|
+
var GetDelCommand = class extends Command {
|
|
732
|
+
constructor(cmd, opts) {
|
|
733
|
+
super(["getdel", ...cmd], opts);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
// pkg/commands/getrange.ts
|
|
738
|
+
var GetRangeCommand = class extends Command {
|
|
739
|
+
constructor(cmd, opts) {
|
|
740
|
+
super(["getrange", ...cmd], opts);
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
// pkg/commands/getset.ts
|
|
745
|
+
var GetSetCommand = class extends Command {
|
|
746
|
+
constructor(cmd, opts) {
|
|
747
|
+
super(["getset", ...cmd], opts);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
// pkg/commands/hdel.ts
|
|
752
|
+
var HDelCommand = class extends Command {
|
|
753
|
+
constructor(cmd, opts) {
|
|
754
|
+
super(["hdel", ...cmd], opts);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// pkg/commands/hexists.ts
|
|
759
|
+
var HExistsCommand = class extends Command {
|
|
760
|
+
constructor(cmd, opts) {
|
|
761
|
+
super(["hexists", ...cmd], opts);
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
// pkg/commands/hget.ts
|
|
766
|
+
var HGetCommand = class extends Command {
|
|
767
|
+
constructor(cmd, opts) {
|
|
768
|
+
super(["hget", ...cmd], opts);
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
// pkg/commands/hgetall.ts
|
|
773
|
+
function deserialize(result) {
|
|
774
|
+
if (result.length === 0) {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
const obj = {};
|
|
778
|
+
while (result.length >= 2) {
|
|
779
|
+
const key = result.shift();
|
|
780
|
+
const value = result.shift();
|
|
781
|
+
try {
|
|
782
|
+
const valueIsNumberAndNotSafeInteger = !Number.isNaN(Number(value)) && !Number.isSafeInteger(Number(value));
|
|
783
|
+
obj[key] = valueIsNumberAndNotSafeInteger ? value : JSON.parse(value);
|
|
784
|
+
} catch {
|
|
785
|
+
obj[key] = value;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return obj;
|
|
789
|
+
}
|
|
790
|
+
var HGetAllCommand = class extends Command {
|
|
791
|
+
constructor(cmd, opts) {
|
|
792
|
+
super(["hgetall", ...cmd], {
|
|
793
|
+
deserialize: (result) => deserialize(result),
|
|
794
|
+
...opts
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
// pkg/commands/hincrby.ts
|
|
800
|
+
var HIncrByCommand = class extends Command {
|
|
801
|
+
constructor(cmd, opts) {
|
|
802
|
+
super(["hincrby", ...cmd], opts);
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
// pkg/commands/hincrbyfloat.ts
|
|
807
|
+
var HIncrByFloatCommand = class extends Command {
|
|
808
|
+
constructor(cmd, opts) {
|
|
809
|
+
super(["hincrbyfloat", ...cmd], opts);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
// pkg/commands/hkeys.ts
|
|
814
|
+
var HKeysCommand = class extends Command {
|
|
815
|
+
constructor([key], opts) {
|
|
816
|
+
super(["hkeys", key], opts);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
// pkg/commands/hlen.ts
|
|
821
|
+
var HLenCommand = class extends Command {
|
|
822
|
+
constructor(cmd, opts) {
|
|
823
|
+
super(["hlen", ...cmd], opts);
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
// pkg/commands/hmget.ts
|
|
828
|
+
function deserialize2(fields, result) {
|
|
829
|
+
if (result.every((field) => field === null)) {
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
const obj = {};
|
|
833
|
+
for (const [i, field] of fields.entries()) {
|
|
834
|
+
try {
|
|
835
|
+
obj[field] = JSON.parse(result[i]);
|
|
836
|
+
} catch {
|
|
837
|
+
obj[field] = result[i];
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return obj;
|
|
841
|
+
}
|
|
842
|
+
var HMGetCommand = class extends Command {
|
|
843
|
+
constructor([key, ...fields], opts) {
|
|
844
|
+
super(["hmget", key, ...fields], {
|
|
845
|
+
deserialize: (result) => deserialize2(fields, result),
|
|
846
|
+
...opts
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
// pkg/commands/hmset.ts
|
|
852
|
+
var HMSetCommand = class extends Command {
|
|
853
|
+
constructor([key, kv], opts) {
|
|
854
|
+
super(["hmset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
// pkg/commands/hrandfield.ts
|
|
859
|
+
function deserialize3(result) {
|
|
860
|
+
if (result.length === 0) {
|
|
861
|
+
return null;
|
|
862
|
+
}
|
|
863
|
+
const obj = {};
|
|
864
|
+
while (result.length >= 2) {
|
|
865
|
+
const key = result.shift();
|
|
866
|
+
const value = result.shift();
|
|
867
|
+
try {
|
|
868
|
+
obj[key] = JSON.parse(value);
|
|
869
|
+
} catch {
|
|
870
|
+
obj[key] = value;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
return obj;
|
|
874
|
+
}
|
|
875
|
+
var HRandFieldCommand = class extends Command {
|
|
876
|
+
constructor(cmd, opts) {
|
|
877
|
+
const command = ["hrandfield", cmd[0]];
|
|
878
|
+
if (typeof cmd[1] === "number") {
|
|
879
|
+
command.push(cmd[1]);
|
|
880
|
+
}
|
|
881
|
+
if (cmd[2]) {
|
|
882
|
+
command.push("WITHVALUES");
|
|
883
|
+
}
|
|
884
|
+
super(command, {
|
|
885
|
+
// @ts-expect-error to silence compiler
|
|
886
|
+
deserialize: cmd[2] ? (result) => deserialize3(result) : opts?.deserialize,
|
|
887
|
+
...opts
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
// pkg/commands/hscan.ts
|
|
893
|
+
var HScanCommand = class extends Command {
|
|
894
|
+
constructor([key, cursor, cmdOpts], opts) {
|
|
895
|
+
const command = ["hscan", key, cursor];
|
|
896
|
+
if (cmdOpts?.match) {
|
|
897
|
+
command.push("match", cmdOpts.match);
|
|
898
|
+
}
|
|
899
|
+
if (typeof cmdOpts?.count === "number") {
|
|
900
|
+
command.push("count", cmdOpts.count);
|
|
901
|
+
}
|
|
902
|
+
super(command, {
|
|
903
|
+
deserialize: deserializeScanResponse,
|
|
904
|
+
...opts
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
// pkg/commands/hset.ts
|
|
910
|
+
var HSetCommand = class extends Command {
|
|
911
|
+
constructor([key, kv], opts) {
|
|
912
|
+
super(["hset", key, ...Object.entries(kv).flatMap(([field, value]) => [field, value])], opts);
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
// pkg/commands/hsetnx.ts
|
|
917
|
+
var HSetNXCommand = class extends Command {
|
|
918
|
+
constructor(cmd, opts) {
|
|
919
|
+
super(["hsetnx", ...cmd], opts);
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
// pkg/commands/hstrlen.ts
|
|
924
|
+
var HStrLenCommand = class extends Command {
|
|
925
|
+
constructor(cmd, opts) {
|
|
926
|
+
super(["hstrlen", ...cmd], opts);
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
// pkg/commands/hvals.ts
|
|
931
|
+
var HValsCommand = class extends Command {
|
|
932
|
+
constructor(cmd, opts) {
|
|
933
|
+
super(["hvals", ...cmd], opts);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
// pkg/commands/incr.ts
|
|
938
|
+
var IncrCommand = class extends Command {
|
|
939
|
+
constructor(cmd, opts) {
|
|
940
|
+
super(["incr", ...cmd], opts);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
// pkg/commands/incrby.ts
|
|
945
|
+
var IncrByCommand = class extends Command {
|
|
946
|
+
constructor(cmd, opts) {
|
|
947
|
+
super(["incrby", ...cmd], opts);
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
// pkg/commands/incrbyfloat.ts
|
|
952
|
+
var IncrByFloatCommand = class extends Command {
|
|
953
|
+
constructor(cmd, opts) {
|
|
954
|
+
super(["incrbyfloat", ...cmd], opts);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
// pkg/commands/json_arrappend.ts
|
|
959
|
+
var JsonArrAppendCommand = class extends Command {
|
|
960
|
+
constructor(cmd, opts) {
|
|
961
|
+
super(["JSON.ARRAPPEND", ...cmd], opts);
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
// pkg/commands/json_arrindex.ts
|
|
966
|
+
var JsonArrIndexCommand = class extends Command {
|
|
967
|
+
constructor(cmd, opts) {
|
|
968
|
+
super(["JSON.ARRINDEX", ...cmd], opts);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// pkg/commands/json_arrinsert.ts
|
|
973
|
+
var JsonArrInsertCommand = class extends Command {
|
|
974
|
+
constructor(cmd, opts) {
|
|
975
|
+
super(["JSON.ARRINSERT", ...cmd], opts);
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
// pkg/commands/json_arrlen.ts
|
|
980
|
+
var JsonArrLenCommand = class extends Command {
|
|
981
|
+
constructor(cmd, opts) {
|
|
982
|
+
super(["JSON.ARRLEN", cmd[0], cmd[1] ?? "$"], opts);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
// pkg/commands/json_arrpop.ts
|
|
987
|
+
var JsonArrPopCommand = class extends Command {
|
|
988
|
+
constructor(cmd, opts) {
|
|
989
|
+
super(["JSON.ARRPOP", ...cmd], opts);
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
// pkg/commands/json_arrtrim.ts
|
|
994
|
+
var JsonArrTrimCommand = class extends Command {
|
|
995
|
+
constructor(cmd, opts) {
|
|
996
|
+
const path = cmd[1] ?? "$";
|
|
997
|
+
const start = cmd[2] ?? 0;
|
|
998
|
+
const stop = cmd[3] ?? 0;
|
|
999
|
+
super(["JSON.ARRTRIM", cmd[0], path, start, stop], opts);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// pkg/commands/json_clear.ts
|
|
1004
|
+
var JsonClearCommand = class extends Command {
|
|
1005
|
+
constructor(cmd, opts) {
|
|
1006
|
+
super(["JSON.CLEAR", ...cmd], opts);
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// pkg/commands/json_del.ts
|
|
1011
|
+
var JsonDelCommand = class extends Command {
|
|
1012
|
+
constructor(cmd, opts) {
|
|
1013
|
+
super(["JSON.DEL", ...cmd], opts);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
// pkg/commands/json_forget.ts
|
|
1018
|
+
var JsonForgetCommand = class extends Command {
|
|
1019
|
+
constructor(cmd, opts) {
|
|
1020
|
+
super(["JSON.FORGET", ...cmd], opts);
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
// pkg/commands/json_get.ts
|
|
1025
|
+
var JsonGetCommand = class extends Command {
|
|
1026
|
+
constructor(cmd, opts) {
|
|
1027
|
+
const command = ["JSON.GET"];
|
|
1028
|
+
if (typeof cmd[1] === "string") {
|
|
1029
|
+
command.push(...cmd);
|
|
1030
|
+
} else {
|
|
1031
|
+
command.push(cmd[0]);
|
|
1032
|
+
if (cmd[1]) {
|
|
1033
|
+
if (cmd[1].indent) {
|
|
1034
|
+
command.push("INDENT", cmd[1].indent);
|
|
1035
|
+
}
|
|
1036
|
+
if (cmd[1].newline) {
|
|
1037
|
+
command.push("NEWLINE", cmd[1].newline);
|
|
1038
|
+
}
|
|
1039
|
+
if (cmd[1].space) {
|
|
1040
|
+
command.push("SPACE", cmd[1].space);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
command.push(...cmd.slice(2));
|
|
1044
|
+
}
|
|
1045
|
+
super(command, opts);
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
// pkg/commands/json_mget.ts
|
|
1050
|
+
var JsonMGetCommand = class extends Command {
|
|
1051
|
+
constructor(cmd, opts) {
|
|
1052
|
+
super(["JSON.MGET", ...cmd[0], cmd[1]], opts);
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// pkg/commands/json_mset.ts
|
|
1057
|
+
var JsonMSetCommand = class extends Command {
|
|
1058
|
+
constructor(cmd, opts) {
|
|
1059
|
+
const command = ["JSON.MSET"];
|
|
1060
|
+
for (const c of cmd) {
|
|
1061
|
+
command.push(c.key, c.path, c.value);
|
|
1062
|
+
}
|
|
1063
|
+
super(command, opts);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// pkg/commands/json_numincrby.ts
|
|
1068
|
+
var JsonNumIncrByCommand = class extends Command {
|
|
1069
|
+
constructor(cmd, opts) {
|
|
1070
|
+
super(["JSON.NUMINCRBY", ...cmd], opts);
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
// pkg/commands/json_nummultby.ts
|
|
1075
|
+
var JsonNumMultByCommand = class extends Command {
|
|
1076
|
+
constructor(cmd, opts) {
|
|
1077
|
+
super(["JSON.NUMMULTBY", ...cmd], opts);
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
// pkg/commands/json_objkeys.ts
|
|
1082
|
+
var JsonObjKeysCommand = class extends Command {
|
|
1083
|
+
constructor(cmd, opts) {
|
|
1084
|
+
super(["JSON.OBJKEYS", ...cmd], opts);
|
|
1085
|
+
}
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// pkg/commands/json_objlen.ts
|
|
1089
|
+
var JsonObjLenCommand = class extends Command {
|
|
1090
|
+
constructor(cmd, opts) {
|
|
1091
|
+
super(["JSON.OBJLEN", ...cmd], opts);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// pkg/commands/json_resp.ts
|
|
1096
|
+
var JsonRespCommand = class extends Command {
|
|
1097
|
+
constructor(cmd, opts) {
|
|
1098
|
+
super(["JSON.RESP", ...cmd], opts);
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// pkg/commands/json_set.ts
|
|
1103
|
+
var JsonSetCommand = class extends Command {
|
|
1104
|
+
constructor(cmd, opts) {
|
|
1105
|
+
const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]];
|
|
1106
|
+
if (cmd[3]) {
|
|
1107
|
+
if (cmd[3].nx) {
|
|
1108
|
+
command.push("NX");
|
|
1109
|
+
} else if (cmd[3].xx) {
|
|
1110
|
+
command.push("XX");
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
super(command, opts);
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
// pkg/commands/json_strappend.ts
|
|
1118
|
+
var JsonStrAppendCommand = class extends Command {
|
|
1119
|
+
constructor(cmd, opts) {
|
|
1120
|
+
super(["JSON.STRAPPEND", ...cmd], opts);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// pkg/commands/json_strlen.ts
|
|
1125
|
+
var JsonStrLenCommand = class extends Command {
|
|
1126
|
+
constructor(cmd, opts) {
|
|
1127
|
+
super(["JSON.STRLEN", ...cmd], opts);
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
// pkg/commands/json_toggle.ts
|
|
1132
|
+
var JsonToggleCommand = class extends Command {
|
|
1133
|
+
constructor(cmd, opts) {
|
|
1134
|
+
super(["JSON.TOGGLE", ...cmd], opts);
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
// pkg/commands/json_type.ts
|
|
1139
|
+
var JsonTypeCommand = class extends Command {
|
|
1140
|
+
constructor(cmd, opts) {
|
|
1141
|
+
super(["JSON.TYPE", ...cmd], opts);
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
// pkg/commands/keys.ts
|
|
1146
|
+
var KeysCommand = class extends Command {
|
|
1147
|
+
constructor(cmd, opts) {
|
|
1148
|
+
super(["keys", ...cmd], opts);
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
// pkg/commands/lindex.ts
|
|
1153
|
+
var LIndexCommand = class extends Command {
|
|
1154
|
+
constructor(cmd, opts) {
|
|
1155
|
+
super(["lindex", ...cmd], opts);
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// pkg/commands/linsert.ts
|
|
1160
|
+
var LInsertCommand = class extends Command {
|
|
1161
|
+
constructor(cmd, opts) {
|
|
1162
|
+
super(["linsert", ...cmd], opts);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
// pkg/commands/llen.ts
|
|
1167
|
+
var LLenCommand = class extends Command {
|
|
1168
|
+
constructor(cmd, opts) {
|
|
1169
|
+
super(["llen", ...cmd], opts);
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
// pkg/commands/lmove.ts
|
|
1174
|
+
var LMoveCommand = class extends Command {
|
|
1175
|
+
constructor(cmd, opts) {
|
|
1176
|
+
super(["lmove", ...cmd], opts);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
// pkg/commands/lmpop.ts
|
|
1181
|
+
var LmPopCommand = class extends Command {
|
|
1182
|
+
constructor(cmd, opts) {
|
|
1183
|
+
const [numkeys, keys, direction, count] = cmd;
|
|
1184
|
+
super(["LMPOP", numkeys, ...keys, direction, ...count ? ["COUNT", count] : []], opts);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
// pkg/commands/lpop.ts
|
|
1189
|
+
var LPopCommand = class extends Command {
|
|
1190
|
+
constructor(cmd, opts) {
|
|
1191
|
+
super(["lpop", ...cmd], opts);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// pkg/commands/lpos.ts
|
|
1196
|
+
var LPosCommand = class extends Command {
|
|
1197
|
+
constructor(cmd, opts) {
|
|
1198
|
+
const args = ["lpos", cmd[0], cmd[1]];
|
|
1199
|
+
if (typeof cmd[2]?.rank === "number") {
|
|
1200
|
+
args.push("rank", cmd[2].rank);
|
|
1201
|
+
}
|
|
1202
|
+
if (typeof cmd[2]?.count === "number") {
|
|
1203
|
+
args.push("count", cmd[2].count);
|
|
1204
|
+
}
|
|
1205
|
+
if (typeof cmd[2]?.maxLen === "number") {
|
|
1206
|
+
args.push("maxLen", cmd[2].maxLen);
|
|
1207
|
+
}
|
|
1208
|
+
super(args, opts);
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
// pkg/commands/lpush.ts
|
|
1213
|
+
var LPushCommand = class extends Command {
|
|
1214
|
+
constructor(cmd, opts) {
|
|
1215
|
+
super(["lpush", ...cmd], opts);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// pkg/commands/lpushx.ts
|
|
1220
|
+
var LPushXCommand = class extends Command {
|
|
1221
|
+
constructor(cmd, opts) {
|
|
1222
|
+
super(["lpushx", ...cmd], opts);
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
// pkg/commands/lrange.ts
|
|
1227
|
+
var LRangeCommand = class extends Command {
|
|
1228
|
+
constructor(cmd, opts) {
|
|
1229
|
+
super(["lrange", ...cmd], opts);
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// pkg/commands/lrem.ts
|
|
1234
|
+
var LRemCommand = class extends Command {
|
|
1235
|
+
constructor(cmd, opts) {
|
|
1236
|
+
super(["lrem", ...cmd], opts);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
// pkg/commands/lset.ts
|
|
1241
|
+
var LSetCommand = class extends Command {
|
|
1242
|
+
constructor(cmd, opts) {
|
|
1243
|
+
super(["lset", ...cmd], opts);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
// pkg/commands/ltrim.ts
|
|
1248
|
+
var LTrimCommand = class extends Command {
|
|
1249
|
+
constructor(cmd, opts) {
|
|
1250
|
+
super(["ltrim", ...cmd], opts);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
// pkg/commands/mget.ts
|
|
1255
|
+
var MGetCommand = class extends Command {
|
|
1256
|
+
constructor(cmd, opts) {
|
|
1257
|
+
const keys = Array.isArray(cmd[0]) ? cmd[0] : cmd;
|
|
1258
|
+
super(["mget", ...keys], opts);
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
// pkg/commands/mset.ts
|
|
1263
|
+
var MSetCommand = class extends Command {
|
|
1264
|
+
constructor([kv], opts) {
|
|
1265
|
+
super(["mset", ...Object.entries(kv).flatMap(([key, value]) => [key, value])], opts);
|
|
1266
|
+
}
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1269
|
+
// pkg/commands/msetnx.ts
|
|
1270
|
+
var MSetNXCommand = class extends Command {
|
|
1271
|
+
constructor([kv], opts) {
|
|
1272
|
+
super(["msetnx", ...Object.entries(kv).flat()], opts);
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
// pkg/commands/persist.ts
|
|
1277
|
+
var PersistCommand = class extends Command {
|
|
1278
|
+
constructor(cmd, opts) {
|
|
1279
|
+
super(["persist", ...cmd], opts);
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
// pkg/commands/pexpire.ts
|
|
1284
|
+
var PExpireCommand = class extends Command {
|
|
1285
|
+
constructor(cmd, opts) {
|
|
1286
|
+
super(["pexpire", ...cmd], opts);
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
|
|
1290
|
+
// pkg/commands/pexpireat.ts
|
|
1291
|
+
var PExpireAtCommand = class extends Command {
|
|
1292
|
+
constructor(cmd, opts) {
|
|
1293
|
+
super(["pexpireat", ...cmd], opts);
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
// pkg/commands/pfadd.ts
|
|
1298
|
+
var PfAddCommand = class extends Command {
|
|
1299
|
+
constructor(cmd, opts) {
|
|
1300
|
+
super(["pfadd", ...cmd], opts);
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
// pkg/commands/pfcount.ts
|
|
1305
|
+
var PfCountCommand = class extends Command {
|
|
1306
|
+
constructor(cmd, opts) {
|
|
1307
|
+
super(["pfcount", ...cmd], opts);
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
// pkg/commands/pfmerge.ts
|
|
1312
|
+
var PfMergeCommand = class extends Command {
|
|
1313
|
+
constructor(cmd, opts) {
|
|
1314
|
+
super(["pfmerge", ...cmd], opts);
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
// pkg/commands/ping.ts
|
|
1319
|
+
var PingCommand = class extends Command {
|
|
1320
|
+
constructor(cmd, opts) {
|
|
1321
|
+
const command = ["ping"];
|
|
1322
|
+
if (cmd?.[0] !== void 0) {
|
|
1323
|
+
command.push(cmd[0]);
|
|
1324
|
+
}
|
|
1325
|
+
super(command, opts);
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
// pkg/commands/psetex.ts
|
|
1330
|
+
var PSetEXCommand = class extends Command {
|
|
1331
|
+
constructor(cmd, opts) {
|
|
1332
|
+
super(["psetex", ...cmd], opts);
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
// pkg/commands/pttl.ts
|
|
1337
|
+
var PTtlCommand = class extends Command {
|
|
1338
|
+
constructor(cmd, opts) {
|
|
1339
|
+
super(["pttl", ...cmd], opts);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
// pkg/commands/publish.ts
|
|
1344
|
+
var PublishCommand = class extends Command {
|
|
1345
|
+
constructor(cmd, opts) {
|
|
1346
|
+
super(["publish", ...cmd], opts);
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1350
|
+
// pkg/commands/randomkey.ts
|
|
1351
|
+
var RandomKeyCommand = class extends Command {
|
|
1352
|
+
constructor(opts) {
|
|
1353
|
+
super(["randomkey"], opts);
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
// pkg/commands/rename.ts
|
|
1358
|
+
var RenameCommand = class extends Command {
|
|
1359
|
+
constructor(cmd, opts) {
|
|
1360
|
+
super(["rename", ...cmd], opts);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
// pkg/commands/renamenx.ts
|
|
1365
|
+
var RenameNXCommand = class extends Command {
|
|
1366
|
+
constructor(cmd, opts) {
|
|
1367
|
+
super(["renamenx", ...cmd], opts);
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
// pkg/commands/rpop.ts
|
|
1372
|
+
var RPopCommand = class extends Command {
|
|
1373
|
+
constructor(cmd, opts) {
|
|
1374
|
+
super(["rpop", ...cmd], opts);
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
|
|
1378
|
+
// pkg/commands/rpush.ts
|
|
1379
|
+
var RPushCommand = class extends Command {
|
|
1380
|
+
constructor(cmd, opts) {
|
|
1381
|
+
super(["rpush", ...cmd], opts);
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
// pkg/commands/rpushx.ts
|
|
1386
|
+
var RPushXCommand = class extends Command {
|
|
1387
|
+
constructor(cmd, opts) {
|
|
1388
|
+
super(["rpushx", ...cmd], opts);
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
// pkg/commands/sadd.ts
|
|
1393
|
+
var SAddCommand = class extends Command {
|
|
1394
|
+
constructor(cmd, opts) {
|
|
1395
|
+
super(["sadd", ...cmd], opts);
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1399
|
+
// pkg/commands/scan.ts
|
|
1400
|
+
var ScanCommand = class extends Command {
|
|
1401
|
+
constructor([cursor, opts], cmdOpts) {
|
|
1402
|
+
const command = ["scan", cursor];
|
|
1403
|
+
if (opts?.match) {
|
|
1404
|
+
command.push("match", opts.match);
|
|
1405
|
+
}
|
|
1406
|
+
if (typeof opts?.count === "number") {
|
|
1407
|
+
command.push("count", opts.count);
|
|
1408
|
+
}
|
|
1409
|
+
if (opts?.type && opts.type.length > 0) {
|
|
1410
|
+
command.push("type", opts.type);
|
|
1411
|
+
}
|
|
1412
|
+
super(command, {
|
|
1413
|
+
deserialize: deserializeScanResponse,
|
|
1414
|
+
...cmdOpts
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
|
|
1419
|
+
// pkg/commands/scard.ts
|
|
1420
|
+
var SCardCommand = class extends Command {
|
|
1421
|
+
constructor(cmd, opts) {
|
|
1422
|
+
super(["scard", ...cmd], opts);
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
// pkg/commands/script_exists.ts
|
|
1427
|
+
var ScriptExistsCommand = class extends Command {
|
|
1428
|
+
constructor(hashes, opts) {
|
|
1429
|
+
super(["script", "exists", ...hashes], {
|
|
1430
|
+
deserialize: (result) => result,
|
|
1431
|
+
...opts
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
// pkg/commands/script_flush.ts
|
|
1437
|
+
var ScriptFlushCommand = class extends Command {
|
|
1438
|
+
constructor([opts], cmdOpts) {
|
|
1439
|
+
const cmd = ["script", "flush"];
|
|
1440
|
+
if (opts?.sync) {
|
|
1441
|
+
cmd.push("sync");
|
|
1442
|
+
} else if (opts?.async) {
|
|
1443
|
+
cmd.push("async");
|
|
1444
|
+
}
|
|
1445
|
+
super(cmd, cmdOpts);
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
|
|
1449
|
+
// pkg/commands/script_load.ts
|
|
1450
|
+
var ScriptLoadCommand = class extends Command {
|
|
1451
|
+
constructor(args, opts) {
|
|
1452
|
+
super(["script", "load", ...args], opts);
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
// pkg/commands/sdiff.ts
|
|
1457
|
+
var SDiffCommand = class extends Command {
|
|
1458
|
+
constructor(cmd, opts) {
|
|
1459
|
+
super(["sdiff", ...cmd], opts);
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
// pkg/commands/sdiffstore.ts
|
|
1464
|
+
var SDiffStoreCommand = class extends Command {
|
|
1465
|
+
constructor(cmd, opts) {
|
|
1466
|
+
super(["sdiffstore", ...cmd], opts);
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
// pkg/commands/set.ts
|
|
1471
|
+
var SetCommand = class extends Command {
|
|
1472
|
+
constructor([key, value, opts], cmdOpts) {
|
|
1473
|
+
const command = ["set", key, value];
|
|
1474
|
+
if (opts) {
|
|
1475
|
+
if ("nx" in opts && opts.nx) {
|
|
1476
|
+
command.push("nx");
|
|
1477
|
+
} else if ("xx" in opts && opts.xx) {
|
|
1478
|
+
command.push("xx");
|
|
1479
|
+
}
|
|
1480
|
+
if ("get" in opts && opts.get) {
|
|
1481
|
+
command.push("get");
|
|
1482
|
+
}
|
|
1483
|
+
if ("ex" in opts && typeof opts.ex === "number") {
|
|
1484
|
+
command.push("ex", opts.ex);
|
|
1485
|
+
} else if ("px" in opts && typeof opts.px === "number") {
|
|
1486
|
+
command.push("px", opts.px);
|
|
1487
|
+
} else if ("exat" in opts && typeof opts.exat === "number") {
|
|
1488
|
+
command.push("exat", opts.exat);
|
|
1489
|
+
} else if ("pxat" in opts && typeof opts.pxat === "number") {
|
|
1490
|
+
command.push("pxat", opts.pxat);
|
|
1491
|
+
} else if ("keepTtl" in opts && opts.keepTtl) {
|
|
1492
|
+
command.push("keepTtl");
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
super(command, cmdOpts);
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
// pkg/commands/setbit.ts
|
|
1500
|
+
var SetBitCommand = class extends Command {
|
|
1501
|
+
constructor(cmd, opts) {
|
|
1502
|
+
super(["setbit", ...cmd], opts);
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
// pkg/commands/setex.ts
|
|
1507
|
+
var SetExCommand = class extends Command {
|
|
1508
|
+
constructor(cmd, opts) {
|
|
1509
|
+
super(["setex", ...cmd], opts);
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
// pkg/commands/setnx.ts
|
|
1514
|
+
var SetNxCommand = class extends Command {
|
|
1515
|
+
constructor(cmd, opts) {
|
|
1516
|
+
super(["setnx", ...cmd], opts);
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
// pkg/commands/setrange.ts
|
|
1521
|
+
var SetRangeCommand = class extends Command {
|
|
1522
|
+
constructor(cmd, opts) {
|
|
1523
|
+
super(["setrange", ...cmd], opts);
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
|
|
1527
|
+
// pkg/commands/sinter.ts
|
|
1528
|
+
var SInterCommand = class extends Command {
|
|
1529
|
+
constructor(cmd, opts) {
|
|
1530
|
+
super(["sinter", ...cmd], opts);
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
// pkg/commands/sinterstore.ts
|
|
1535
|
+
var SInterStoreCommand = class extends Command {
|
|
1536
|
+
constructor(cmd, opts) {
|
|
1537
|
+
super(["sinterstore", ...cmd], opts);
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1541
|
+
// pkg/commands/sismember.ts
|
|
1542
|
+
var SIsMemberCommand = class extends Command {
|
|
1543
|
+
constructor(cmd, opts) {
|
|
1544
|
+
super(["sismember", ...cmd], opts);
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
// pkg/commands/smembers.ts
|
|
1549
|
+
var SMembersCommand = class extends Command {
|
|
1550
|
+
constructor(cmd, opts) {
|
|
1551
|
+
super(["smembers", ...cmd], opts);
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
// pkg/commands/smismember.ts
|
|
1556
|
+
var SMIsMemberCommand = class extends Command {
|
|
1557
|
+
constructor(cmd, opts) {
|
|
1558
|
+
super(["smismember", cmd[0], ...cmd[1]], opts);
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
|
|
1562
|
+
// pkg/commands/smove.ts
|
|
1563
|
+
var SMoveCommand = class extends Command {
|
|
1564
|
+
constructor(cmd, opts) {
|
|
1565
|
+
super(["smove", ...cmd], opts);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
// pkg/commands/spop.ts
|
|
1570
|
+
var SPopCommand = class extends Command {
|
|
1571
|
+
constructor([key, count], opts) {
|
|
1572
|
+
const command = ["spop", key];
|
|
1573
|
+
if (typeof count === "number") {
|
|
1574
|
+
command.push(count);
|
|
1575
|
+
}
|
|
1576
|
+
super(command, opts);
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
// pkg/commands/srandmember.ts
|
|
1581
|
+
var SRandMemberCommand = class extends Command {
|
|
1582
|
+
constructor([key, count], opts) {
|
|
1583
|
+
const command = ["srandmember", key];
|
|
1584
|
+
if (typeof count === "number") {
|
|
1585
|
+
command.push(count);
|
|
1586
|
+
}
|
|
1587
|
+
super(command, opts);
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1591
|
+
// pkg/commands/srem.ts
|
|
1592
|
+
var SRemCommand = class extends Command {
|
|
1593
|
+
constructor(cmd, opts) {
|
|
1594
|
+
super(["srem", ...cmd], opts);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
// pkg/commands/sscan.ts
|
|
1599
|
+
var SScanCommand = class extends Command {
|
|
1600
|
+
constructor([key, cursor, opts], cmdOpts) {
|
|
1601
|
+
const command = ["sscan", key, cursor];
|
|
1602
|
+
if (opts?.match) {
|
|
1603
|
+
command.push("match", opts.match);
|
|
1604
|
+
}
|
|
1605
|
+
if (typeof opts?.count === "number") {
|
|
1606
|
+
command.push("count", opts.count);
|
|
1607
|
+
}
|
|
1608
|
+
super(command, {
|
|
1609
|
+
deserialize: deserializeScanResponse,
|
|
1610
|
+
...cmdOpts
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1615
|
+
// pkg/commands/strlen.ts
|
|
1616
|
+
var StrLenCommand = class extends Command {
|
|
1617
|
+
constructor(cmd, opts) {
|
|
1618
|
+
super(["strlen", ...cmd], opts);
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
// pkg/commands/sunion.ts
|
|
1623
|
+
var SUnionCommand = class extends Command {
|
|
1624
|
+
constructor(cmd, opts) {
|
|
1625
|
+
super(["sunion", ...cmd], opts);
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
// pkg/commands/sunionstore.ts
|
|
1630
|
+
var SUnionStoreCommand = class extends Command {
|
|
1631
|
+
constructor(cmd, opts) {
|
|
1632
|
+
super(["sunionstore", ...cmd], opts);
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// pkg/commands/time.ts
|
|
1637
|
+
var TimeCommand = class extends Command {
|
|
1638
|
+
constructor(opts) {
|
|
1639
|
+
super(["time"], opts);
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
// pkg/commands/touch.ts
|
|
1644
|
+
var TouchCommand = class extends Command {
|
|
1645
|
+
constructor(cmd, opts) {
|
|
1646
|
+
super(["touch", ...cmd], opts);
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1650
|
+
// pkg/commands/ttl.ts
|
|
1651
|
+
var TtlCommand = class extends Command {
|
|
1652
|
+
constructor(cmd, opts) {
|
|
1653
|
+
super(["ttl", ...cmd], opts);
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
// pkg/commands/type.ts
|
|
1658
|
+
var TypeCommand = class extends Command {
|
|
1659
|
+
constructor(cmd, opts) {
|
|
1660
|
+
super(["type", ...cmd], opts);
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
|
|
1664
|
+
// pkg/commands/unlink.ts
|
|
1665
|
+
var UnlinkCommand = class extends Command {
|
|
1666
|
+
constructor(cmd, opts) {
|
|
1667
|
+
super(["unlink", ...cmd], opts);
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
// pkg/commands/xack.ts
|
|
1672
|
+
var XAckCommand = class extends Command {
|
|
1673
|
+
constructor([key, group, id], opts) {
|
|
1674
|
+
const ids = Array.isArray(id) ? [...id] : [id];
|
|
1675
|
+
super(["XACK", key, group, ...ids], opts);
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1679
|
+
// pkg/commands/xadd.ts
|
|
1680
|
+
var XAddCommand = class extends Command {
|
|
1681
|
+
constructor([key, id, entries, opts], commandOptions) {
|
|
1682
|
+
const command = ["XADD", key];
|
|
1683
|
+
if (opts) {
|
|
1684
|
+
if (opts.nomkStream) {
|
|
1685
|
+
command.push("NOMKSTREAM");
|
|
1686
|
+
}
|
|
1687
|
+
if (opts.trim) {
|
|
1688
|
+
command.push(opts.trim.type, opts.trim.comparison, opts.trim.threshold);
|
|
1689
|
+
if (opts.trim.limit !== void 0) {
|
|
1690
|
+
command.push("LIMIT", opts.trim.limit);
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
command.push(id);
|
|
1695
|
+
for (const [k, v] of Object.entries(entries)) {
|
|
1696
|
+
command.push(k, v);
|
|
1697
|
+
}
|
|
1698
|
+
super(command, commandOptions);
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
// pkg/commands/xautoclaim.ts
|
|
1703
|
+
var XAutoClaim = class extends Command {
|
|
1704
|
+
constructor([key, group, consumer, minIdleTime, start, options], opts) {
|
|
1705
|
+
const commands = [];
|
|
1706
|
+
if (options?.count) {
|
|
1707
|
+
commands.push("COUNT", options.count);
|
|
1708
|
+
}
|
|
1709
|
+
if (options?.justId) {
|
|
1710
|
+
commands.push("JUSTID");
|
|
1711
|
+
}
|
|
1712
|
+
super(["XAUTOCLAIM", key, group, consumer, minIdleTime, start, ...commands], opts);
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
// pkg/commands/xclaim.ts
|
|
1717
|
+
var XClaimCommand = class extends Command {
|
|
1718
|
+
constructor([key, group, consumer, minIdleTime, id, options], opts) {
|
|
1719
|
+
const ids = Array.isArray(id) ? [...id] : [id];
|
|
1720
|
+
const commands = [];
|
|
1721
|
+
if (options?.idleMS) {
|
|
1722
|
+
commands.push("IDLE", options.idleMS);
|
|
1723
|
+
}
|
|
1724
|
+
if (options?.idleMS) {
|
|
1725
|
+
commands.push("TIME", options.timeMS);
|
|
1726
|
+
}
|
|
1727
|
+
if (options?.retryCount) {
|
|
1728
|
+
commands.push("RETRYCOUNT", options.retryCount);
|
|
1729
|
+
}
|
|
1730
|
+
if (options?.force) {
|
|
1731
|
+
commands.push("FORCE");
|
|
1732
|
+
}
|
|
1733
|
+
if (options?.justId) {
|
|
1734
|
+
commands.push("JUSTID");
|
|
1735
|
+
}
|
|
1736
|
+
if (options?.lastId) {
|
|
1737
|
+
commands.push("LASTID", options.lastId);
|
|
1738
|
+
}
|
|
1739
|
+
super(["XCLAIM", key, group, consumer, minIdleTime, ...ids, ...commands], opts);
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
|
|
1743
|
+
// pkg/commands/xdel.ts
|
|
1744
|
+
var XDelCommand = class extends Command {
|
|
1745
|
+
constructor([key, ids], opts) {
|
|
1746
|
+
const cmds = Array.isArray(ids) ? [...ids] : [ids];
|
|
1747
|
+
super(["XDEL", key, ...cmds], opts);
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
// pkg/commands/xgroup.ts
|
|
1752
|
+
var XGroupCommand = class extends Command {
|
|
1753
|
+
constructor([key, opts], commandOptions) {
|
|
1754
|
+
const command = ["XGROUP"];
|
|
1755
|
+
switch (opts.type) {
|
|
1756
|
+
case "CREATE": {
|
|
1757
|
+
command.push("CREATE", key, opts.group, opts.id);
|
|
1758
|
+
if (opts.options) {
|
|
1759
|
+
if (opts.options.MKSTREAM) {
|
|
1760
|
+
command.push("MKSTREAM");
|
|
1761
|
+
}
|
|
1762
|
+
if (opts.options.ENTRIESREAD !== void 0) {
|
|
1763
|
+
command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
break;
|
|
1767
|
+
}
|
|
1768
|
+
case "CREATECONSUMER": {
|
|
1769
|
+
command.push("CREATECONSUMER", key, opts.group, opts.consumer);
|
|
1770
|
+
break;
|
|
1771
|
+
}
|
|
1772
|
+
case "DELCONSUMER": {
|
|
1773
|
+
command.push("DELCONSUMER", key, opts.group, opts.consumer);
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1776
|
+
case "DESTROY": {
|
|
1777
|
+
command.push("DESTROY", key, opts.group);
|
|
1778
|
+
break;
|
|
1779
|
+
}
|
|
1780
|
+
case "SETID": {
|
|
1781
|
+
command.push("SETID", key, opts.group, opts.id);
|
|
1782
|
+
if (opts.options?.ENTRIESREAD !== void 0) {
|
|
1783
|
+
command.push("ENTRIESREAD", opts.options.ENTRIESREAD.toString());
|
|
1784
|
+
}
|
|
1785
|
+
break;
|
|
1786
|
+
}
|
|
1787
|
+
default: {
|
|
1788
|
+
throw new Error("Invalid XGROUP");
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
super(command, commandOptions);
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
// pkg/commands/xinfo.ts
|
|
1796
|
+
var XInfoCommand = class extends Command {
|
|
1797
|
+
constructor([key, options], opts) {
|
|
1798
|
+
const cmds = [];
|
|
1799
|
+
if (options.type === "CONSUMERS") {
|
|
1800
|
+
cmds.push("CONSUMERS", key, options.group);
|
|
1801
|
+
} else {
|
|
1802
|
+
cmds.push("GROUPS", key);
|
|
1803
|
+
}
|
|
1804
|
+
super(["XINFO", ...cmds], opts);
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1808
|
+
// pkg/commands/xlen.ts
|
|
1809
|
+
var XLenCommand = class extends Command {
|
|
1810
|
+
constructor(cmd, opts) {
|
|
1811
|
+
super(["XLEN", ...cmd], opts);
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
|
|
1815
|
+
// pkg/commands/xpending.ts
|
|
1816
|
+
var XPendingCommand = class extends Command {
|
|
1817
|
+
constructor([key, group, start, end, count, options], opts) {
|
|
1818
|
+
const consumers = options?.consumer === void 0 ? [] : Array.isArray(options.consumer) ? [...options.consumer] : [options.consumer];
|
|
1819
|
+
super(
|
|
1820
|
+
[
|
|
1821
|
+
"XPENDING",
|
|
1822
|
+
key,
|
|
1823
|
+
group,
|
|
1824
|
+
...options?.idleTime ? ["IDLE", options.idleTime] : [],
|
|
1825
|
+
start,
|
|
1826
|
+
end,
|
|
1827
|
+
count,
|
|
1828
|
+
...consumers
|
|
1829
|
+
],
|
|
1830
|
+
opts
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
// pkg/commands/xrange.ts
|
|
1836
|
+
function deserialize4(result) {
|
|
1837
|
+
const obj = {};
|
|
1838
|
+
for (const e of result) {
|
|
1839
|
+
while (e.length >= 2) {
|
|
1840
|
+
const streamId = e.shift();
|
|
1841
|
+
const entries = e.shift();
|
|
1842
|
+
if (!(streamId in obj)) {
|
|
1843
|
+
obj[streamId] = {};
|
|
1844
|
+
}
|
|
1845
|
+
while (entries.length >= 2) {
|
|
1846
|
+
const field = entries.shift();
|
|
1847
|
+
const value = entries.shift();
|
|
1848
|
+
try {
|
|
1849
|
+
obj[streamId][field] = JSON.parse(value);
|
|
1850
|
+
} catch {
|
|
1851
|
+
obj[streamId][field] = value;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
return obj;
|
|
1857
|
+
}
|
|
1858
|
+
var XRangeCommand = class extends Command {
|
|
1859
|
+
constructor([key, start, end, count], opts) {
|
|
1860
|
+
const command = ["XRANGE", key, start, end];
|
|
1861
|
+
if (typeof count === "number") {
|
|
1862
|
+
command.push("COUNT", count);
|
|
1863
|
+
}
|
|
1864
|
+
super(command, {
|
|
1865
|
+
deserialize: (result) => deserialize4(result),
|
|
1866
|
+
...opts
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
// pkg/commands/xread.ts
|
|
1872
|
+
var UNBALANCED_XREAD_ERR = "ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified";
|
|
1873
|
+
var XReadCommand = class extends Command {
|
|
1874
|
+
constructor([key, id, options], opts) {
|
|
1875
|
+
if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
|
|
1876
|
+
throw new Error(UNBALANCED_XREAD_ERR);
|
|
1877
|
+
}
|
|
1878
|
+
const commands = [];
|
|
1879
|
+
if (typeof options?.count === "number") {
|
|
1880
|
+
commands.push("COUNT", options.count);
|
|
1881
|
+
}
|
|
1882
|
+
if (typeof options?.blockMS === "number") {
|
|
1883
|
+
commands.push("BLOCK", options.blockMS);
|
|
1884
|
+
}
|
|
1885
|
+
commands.push(
|
|
1886
|
+
"STREAMS",
|
|
1887
|
+
...Array.isArray(key) ? [...key] : [key],
|
|
1888
|
+
...Array.isArray(id) ? [...id] : [id]
|
|
1889
|
+
);
|
|
1890
|
+
super(["XREAD", ...commands], opts);
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
// pkg/commands/xreadgroup.ts
|
|
1895
|
+
var UNBALANCED_XREADGROUP_ERR = "ERR Unbalanced XREADGROUP list of streams: for each stream key an ID or '$' must be specified";
|
|
1896
|
+
var XReadGroupCommand = class extends Command {
|
|
1897
|
+
constructor([group, consumer, key, id, options], opts) {
|
|
1898
|
+
if (Array.isArray(key) && Array.isArray(id) && key.length !== id.length) {
|
|
1899
|
+
throw new Error(UNBALANCED_XREADGROUP_ERR);
|
|
1900
|
+
}
|
|
1901
|
+
const commands = [];
|
|
1902
|
+
if (typeof options?.count === "number") {
|
|
1903
|
+
commands.push("COUNT", options.count);
|
|
1904
|
+
}
|
|
1905
|
+
if (typeof options?.blockMS === "number") {
|
|
1906
|
+
commands.push("BLOCK", options.blockMS);
|
|
1907
|
+
}
|
|
1908
|
+
if (typeof options?.NOACK === "boolean" && options.NOACK) {
|
|
1909
|
+
commands.push("NOACK");
|
|
1910
|
+
}
|
|
1911
|
+
commands.push(
|
|
1912
|
+
"STREAMS",
|
|
1913
|
+
...Array.isArray(key) ? [...key] : [key],
|
|
1914
|
+
...Array.isArray(id) ? [...id] : [id]
|
|
1915
|
+
);
|
|
1916
|
+
super(["XREADGROUP", "GROUP", group, consumer, ...commands], opts);
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// pkg/commands/xrevrange.ts
|
|
1921
|
+
var XRevRangeCommand = class extends Command {
|
|
1922
|
+
constructor([key, end, start, count], opts) {
|
|
1923
|
+
const command = ["XREVRANGE", key, end, start];
|
|
1924
|
+
if (typeof count === "number") {
|
|
1925
|
+
command.push("COUNT", count);
|
|
1926
|
+
}
|
|
1927
|
+
super(command, {
|
|
1928
|
+
deserialize: (result) => deserialize5(result),
|
|
1929
|
+
...opts
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1933
|
+
function deserialize5(result) {
|
|
1934
|
+
const obj = {};
|
|
1935
|
+
for (const e of result) {
|
|
1936
|
+
while (e.length >= 2) {
|
|
1937
|
+
const streamId = e.shift();
|
|
1938
|
+
const entries = e.shift();
|
|
1939
|
+
if (!(streamId in obj)) {
|
|
1940
|
+
obj[streamId] = {};
|
|
1941
|
+
}
|
|
1942
|
+
while (entries.length >= 2) {
|
|
1943
|
+
const field = entries.shift();
|
|
1944
|
+
const value = entries.shift();
|
|
1945
|
+
try {
|
|
1946
|
+
obj[streamId][field] = JSON.parse(value);
|
|
1947
|
+
} catch {
|
|
1948
|
+
obj[streamId][field] = value;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
return obj;
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
// pkg/commands/xtrim.ts
|
|
1957
|
+
var XTrimCommand = class extends Command {
|
|
1958
|
+
constructor([key, options], opts) {
|
|
1959
|
+
const { limit, strategy, threshold, exactness = "~" } = options;
|
|
1960
|
+
super(["XTRIM", key, strategy, exactness, threshold, ...limit ? ["LIMIT", limit] : []], opts);
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
|
|
1964
|
+
// pkg/commands/zadd.ts
|
|
1965
|
+
var ZAddCommand = class extends Command {
|
|
1966
|
+
constructor([key, arg1, ...arg2], opts) {
|
|
1967
|
+
const command = ["zadd", key];
|
|
1968
|
+
if ("nx" in arg1 && arg1.nx) {
|
|
1969
|
+
command.push("nx");
|
|
1970
|
+
} else if ("xx" in arg1 && arg1.xx) {
|
|
1971
|
+
command.push("xx");
|
|
1972
|
+
}
|
|
1973
|
+
if ("ch" in arg1 && arg1.ch) {
|
|
1974
|
+
command.push("ch");
|
|
1975
|
+
}
|
|
1976
|
+
if ("incr" in arg1 && arg1.incr) {
|
|
1977
|
+
command.push("incr");
|
|
1978
|
+
}
|
|
1979
|
+
if ("lt" in arg1 && arg1.lt) {
|
|
1980
|
+
command.push("lt");
|
|
1981
|
+
} else if ("gt" in arg1 && arg1.gt) {
|
|
1982
|
+
command.push("gt");
|
|
1983
|
+
}
|
|
1984
|
+
if ("score" in arg1 && "member" in arg1) {
|
|
1985
|
+
command.push(arg1.score, arg1.member);
|
|
1986
|
+
}
|
|
1987
|
+
command.push(...arg2.flatMap(({ score, member }) => [score, member]));
|
|
1988
|
+
super(command, opts);
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1992
|
+
// pkg/commands/zcard.ts
|
|
1993
|
+
var ZCardCommand = class extends Command {
|
|
1994
|
+
constructor(cmd, opts) {
|
|
1995
|
+
super(["zcard", ...cmd], opts);
|
|
1996
|
+
}
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
// pkg/commands/zcount.ts
|
|
2000
|
+
var ZCountCommand = class extends Command {
|
|
2001
|
+
constructor(cmd, opts) {
|
|
2002
|
+
super(["zcount", ...cmd], opts);
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
|
|
2006
|
+
// pkg/commands/zincrby.ts
|
|
2007
|
+
var ZIncrByCommand = class extends Command {
|
|
2008
|
+
constructor(cmd, opts) {
|
|
2009
|
+
super(["zincrby", ...cmd], opts);
|
|
2010
|
+
}
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
// pkg/commands/zinterstore.ts
|
|
2014
|
+
var ZInterStoreCommand = class extends Command {
|
|
2015
|
+
constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
|
|
2016
|
+
const command = ["zinterstore", destination, numKeys];
|
|
2017
|
+
if (Array.isArray(keyOrKeys)) {
|
|
2018
|
+
command.push(...keyOrKeys);
|
|
2019
|
+
} else {
|
|
2020
|
+
command.push(keyOrKeys);
|
|
2021
|
+
}
|
|
2022
|
+
if (opts) {
|
|
2023
|
+
if ("weights" in opts && opts.weights) {
|
|
2024
|
+
command.push("weights", ...opts.weights);
|
|
2025
|
+
} else if ("weight" in opts && typeof opts.weight === "number") {
|
|
2026
|
+
command.push("weights", opts.weight);
|
|
2027
|
+
}
|
|
2028
|
+
if ("aggregate" in opts) {
|
|
2029
|
+
command.push("aggregate", opts.aggregate);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
super(command, cmdOpts);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
// pkg/commands/zlexcount.ts
|
|
2037
|
+
var ZLexCountCommand = class extends Command {
|
|
2038
|
+
constructor(cmd, opts) {
|
|
2039
|
+
super(["zlexcount", ...cmd], opts);
|
|
2040
|
+
}
|
|
2041
|
+
};
|
|
2042
|
+
|
|
2043
|
+
// pkg/commands/zpopmax.ts
|
|
2044
|
+
var ZPopMaxCommand = class extends Command {
|
|
2045
|
+
constructor([key, count], opts) {
|
|
2046
|
+
const command = ["zpopmax", key];
|
|
2047
|
+
if (typeof count === "number") {
|
|
2048
|
+
command.push(count);
|
|
2049
|
+
}
|
|
2050
|
+
super(command, opts);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
|
|
2054
|
+
// pkg/commands/zpopmin.ts
|
|
2055
|
+
var ZPopMinCommand = class extends Command {
|
|
2056
|
+
constructor([key, count], opts) {
|
|
2057
|
+
const command = ["zpopmin", key];
|
|
2058
|
+
if (typeof count === "number") {
|
|
2059
|
+
command.push(count);
|
|
2060
|
+
}
|
|
2061
|
+
super(command, opts);
|
|
2062
|
+
}
|
|
2063
|
+
};
|
|
2064
|
+
|
|
2065
|
+
// pkg/commands/zrange.ts
|
|
2066
|
+
var ZRangeCommand = class extends Command {
|
|
2067
|
+
constructor([key, min, max, opts], cmdOpts) {
|
|
2068
|
+
const command = ["zrange", key, min, max];
|
|
2069
|
+
if (opts?.byScore) {
|
|
2070
|
+
command.push("byscore");
|
|
2071
|
+
}
|
|
2072
|
+
if (opts?.byLex) {
|
|
2073
|
+
command.push("bylex");
|
|
2074
|
+
}
|
|
2075
|
+
if (opts?.rev) {
|
|
2076
|
+
command.push("rev");
|
|
2077
|
+
}
|
|
2078
|
+
if (opts?.count !== void 0 && opts.offset !== void 0) {
|
|
2079
|
+
command.push("limit", opts.offset, opts.count);
|
|
2080
|
+
}
|
|
2081
|
+
if (opts?.withScores) {
|
|
2082
|
+
command.push("withscores");
|
|
2083
|
+
}
|
|
2084
|
+
super(command, cmdOpts);
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
|
|
2088
|
+
// pkg/commands/zrank.ts
|
|
2089
|
+
var ZRankCommand = class extends Command {
|
|
2090
|
+
constructor(cmd, opts) {
|
|
2091
|
+
super(["zrank", ...cmd], opts);
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2094
|
+
|
|
2095
|
+
// pkg/commands/zrem.ts
|
|
2096
|
+
var ZRemCommand = class extends Command {
|
|
2097
|
+
constructor(cmd, opts) {
|
|
2098
|
+
super(["zrem", ...cmd], opts);
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// pkg/commands/zremrangebylex.ts
|
|
2103
|
+
var ZRemRangeByLexCommand = class extends Command {
|
|
2104
|
+
constructor(cmd, opts) {
|
|
2105
|
+
super(["zremrangebylex", ...cmd], opts);
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
|
|
2109
|
+
// pkg/commands/zremrangebyrank.ts
|
|
2110
|
+
var ZRemRangeByRankCommand = class extends Command {
|
|
2111
|
+
constructor(cmd, opts) {
|
|
2112
|
+
super(["zremrangebyrank", ...cmd], opts);
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
// pkg/commands/zremrangebyscore.ts
|
|
2117
|
+
var ZRemRangeByScoreCommand = class extends Command {
|
|
2118
|
+
constructor(cmd, opts) {
|
|
2119
|
+
super(["zremrangebyscore", ...cmd], opts);
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
|
|
2123
|
+
// pkg/commands/zrevrank.ts
|
|
2124
|
+
var ZRevRankCommand = class extends Command {
|
|
2125
|
+
constructor(cmd, opts) {
|
|
2126
|
+
super(["zrevrank", ...cmd], opts);
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
// pkg/commands/zscan.ts
|
|
2131
|
+
var ZScanCommand = class extends Command {
|
|
2132
|
+
constructor([key, cursor, opts], cmdOpts) {
|
|
2133
|
+
const command = ["zscan", key, cursor];
|
|
2134
|
+
if (opts?.match) {
|
|
2135
|
+
command.push("match", opts.match);
|
|
2136
|
+
}
|
|
2137
|
+
if (typeof opts?.count === "number") {
|
|
2138
|
+
command.push("count", opts.count);
|
|
2139
|
+
}
|
|
2140
|
+
super(command, {
|
|
2141
|
+
deserialize: deserializeScanResponse,
|
|
2142
|
+
...cmdOpts
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
// pkg/commands/zscore.ts
|
|
2148
|
+
var ZScoreCommand = class extends Command {
|
|
2149
|
+
constructor(cmd, opts) {
|
|
2150
|
+
super(["zscore", ...cmd], opts);
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
// pkg/commands/zunion.ts
|
|
2155
|
+
var ZUnionCommand = class extends Command {
|
|
2156
|
+
constructor([numKeys, keyOrKeys, opts], cmdOpts) {
|
|
2157
|
+
const command = ["zunion", numKeys];
|
|
2158
|
+
if (Array.isArray(keyOrKeys)) {
|
|
2159
|
+
command.push(...keyOrKeys);
|
|
2160
|
+
} else {
|
|
2161
|
+
command.push(keyOrKeys);
|
|
2162
|
+
}
|
|
2163
|
+
if (opts) {
|
|
2164
|
+
if ("weights" in opts && opts.weights) {
|
|
2165
|
+
command.push("weights", ...opts.weights);
|
|
2166
|
+
} else if ("weight" in opts && typeof opts.weight === "number") {
|
|
2167
|
+
command.push("weights", opts.weight);
|
|
2168
|
+
}
|
|
2169
|
+
if ("aggregate" in opts) {
|
|
2170
|
+
command.push("aggregate", opts.aggregate);
|
|
2171
|
+
}
|
|
2172
|
+
if (opts.withScores) {
|
|
2173
|
+
command.push("withscores");
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
super(command, cmdOpts);
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
|
|
2180
|
+
// pkg/commands/zunionstore.ts
|
|
2181
|
+
var ZUnionStoreCommand = class extends Command {
|
|
2182
|
+
constructor([destination, numKeys, keyOrKeys, opts], cmdOpts) {
|
|
2183
|
+
const command = ["zunionstore", destination, numKeys];
|
|
2184
|
+
if (Array.isArray(keyOrKeys)) {
|
|
2185
|
+
command.push(...keyOrKeys);
|
|
2186
|
+
} else {
|
|
2187
|
+
command.push(keyOrKeys);
|
|
2188
|
+
}
|
|
2189
|
+
if (opts) {
|
|
2190
|
+
if ("weights" in opts && opts.weights) {
|
|
2191
|
+
command.push("weights", ...opts.weights);
|
|
2192
|
+
} else if ("weight" in opts && typeof opts.weight === "number") {
|
|
2193
|
+
command.push("weights", opts.weight);
|
|
2194
|
+
}
|
|
2195
|
+
if ("aggregate" in opts) {
|
|
2196
|
+
command.push("aggregate", opts.aggregate);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
super(command, cmdOpts);
|
|
2200
|
+
}
|
|
2201
|
+
};
|
|
2202
|
+
|
|
2203
|
+
// pkg/commands/zdiffstore.ts
|
|
2204
|
+
var ZDiffStoreCommand = class extends Command {
|
|
2205
|
+
constructor(cmd, opts) {
|
|
2206
|
+
super(["zdiffstore", ...cmd], opts);
|
|
2207
|
+
}
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
// pkg/commands/zmscore.ts
|
|
2211
|
+
var ZMScoreCommand = class extends Command {
|
|
2212
|
+
constructor(cmd, opts) {
|
|
2213
|
+
const [key, members] = cmd;
|
|
2214
|
+
super(["zmscore", key, ...members], opts);
|
|
2215
|
+
}
|
|
2216
|
+
};
|
|
2217
|
+
|
|
2218
|
+
// pkg/pipeline.ts
|
|
2219
|
+
var Pipeline = class {
|
|
2220
|
+
client;
|
|
2221
|
+
commands;
|
|
2222
|
+
commandOptions;
|
|
2223
|
+
multiExec;
|
|
2224
|
+
constructor(opts) {
|
|
2225
|
+
this.client = opts.client;
|
|
2226
|
+
this.commands = [];
|
|
2227
|
+
this.commandOptions = opts.commandOptions;
|
|
2228
|
+
this.multiExec = opts.multiExec ?? false;
|
|
2229
|
+
if (this.commandOptions?.latencyLogging) {
|
|
2230
|
+
const originalExec = this.exec.bind(this);
|
|
2231
|
+
this.exec = async () => {
|
|
2232
|
+
const start = performance.now();
|
|
2233
|
+
const result = await originalExec();
|
|
2234
|
+
const end = performance.now();
|
|
2235
|
+
const loggerResult = (end - start).toFixed(2);
|
|
2236
|
+
console.log(
|
|
2237
|
+
`Latency for \x1B[38;2;19;185;39m${this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase()}\x1B[0m: \x1B[38;2;0;255;255m${loggerResult} ms\x1B[0m`
|
|
2238
|
+
);
|
|
2239
|
+
return result;
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* Send the pipeline request to upstash.
|
|
2245
|
+
*
|
|
2246
|
+
* Returns an array with the results of all pipelined commands.
|
|
2247
|
+
*
|
|
2248
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
2249
|
+
* ```ts
|
|
2250
|
+
* const p = redis.pipeline()
|
|
2251
|
+
* p.get("key")
|
|
2252
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
2253
|
+
* ```
|
|
2254
|
+
*/
|
|
2255
|
+
exec = async () => {
|
|
2256
|
+
if (this.commands.length === 0) {
|
|
2257
|
+
throw new Error("Pipeline is empty");
|
|
2258
|
+
}
|
|
2259
|
+
const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
|
|
2260
|
+
const res = await this.client.request({
|
|
2261
|
+
path,
|
|
2262
|
+
body: Object.values(this.commands).map((c) => c.command)
|
|
2263
|
+
});
|
|
2264
|
+
return res.map(({ error, result }, i) => {
|
|
2265
|
+
if (error) {
|
|
2266
|
+
throw new UpstashError(
|
|
2267
|
+
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
2268
|
+
);
|
|
2269
|
+
}
|
|
2270
|
+
return this.commands[i].deserialize(result);
|
|
2271
|
+
});
|
|
2272
|
+
};
|
|
2273
|
+
/**
|
|
2274
|
+
* Returns the length of pipeline before the execution
|
|
2275
|
+
*/
|
|
2276
|
+
length() {
|
|
2277
|
+
return this.commands.length;
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Pushes a command into the pipeline and returns a chainable instance of the
|
|
2281
|
+
* pipeline
|
|
2282
|
+
*/
|
|
2283
|
+
chain(command) {
|
|
2284
|
+
this.commands.push(command);
|
|
2285
|
+
return this;
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* @see https://redis.io/commands/append
|
|
2289
|
+
*/
|
|
2290
|
+
append = (...args) => this.chain(new AppendCommand(args, this.commandOptions));
|
|
2291
|
+
/**
|
|
2292
|
+
* @see https://redis.io/commands/bitcount
|
|
2293
|
+
*/
|
|
2294
|
+
bitcount = (...args) => this.chain(new BitCountCommand(args, this.commandOptions));
|
|
2295
|
+
/**
|
|
2296
|
+
* Returns an instance that can be used to execute `BITFIELD` commands on one key.
|
|
2297
|
+
*
|
|
2298
|
+
* @example
|
|
2299
|
+
* ```typescript
|
|
2300
|
+
* redis.set("mykey", 0);
|
|
2301
|
+
* const result = await redis.pipeline()
|
|
2302
|
+
* .bitfield("mykey")
|
|
2303
|
+
* .set("u4", 0, 16)
|
|
2304
|
+
* .incr("u4", "#1", 1)
|
|
2305
|
+
* .exec();
|
|
2306
|
+
* console.log(result); // [[0, 1]]
|
|
2307
|
+
* ```
|
|
2308
|
+
*
|
|
2309
|
+
* @see https://redis.io/commands/bitfield
|
|
2310
|
+
*/
|
|
2311
|
+
bitfield = (...args) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
|
|
2312
|
+
/**
|
|
2313
|
+
* @see https://redis.io/commands/bitop
|
|
2314
|
+
*/
|
|
2315
|
+
bitop = (op, destinationKey, sourceKey, ...sourceKeys) => this.chain(
|
|
2316
|
+
new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
|
|
2317
|
+
);
|
|
2318
|
+
/**
|
|
2319
|
+
* @see https://redis.io/commands/bitpos
|
|
2320
|
+
*/
|
|
2321
|
+
bitpos = (...args) => this.chain(new BitPosCommand(args, this.commandOptions));
|
|
2322
|
+
/**
|
|
2323
|
+
* @see https://redis.io/commands/copy
|
|
2324
|
+
*/
|
|
2325
|
+
copy = (...args) => this.chain(new CopyCommand(args, this.commandOptions));
|
|
2326
|
+
/**
|
|
2327
|
+
* @see https://redis.io/commands/zdiffstore
|
|
2328
|
+
*/
|
|
2329
|
+
zdiffstore = (...args) => this.chain(new ZDiffStoreCommand(args, this.commandOptions));
|
|
2330
|
+
/**
|
|
2331
|
+
* @see https://redis.io/commands/dbsize
|
|
2332
|
+
*/
|
|
2333
|
+
dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
|
|
2334
|
+
/**
|
|
2335
|
+
* @see https://redis.io/commands/decr
|
|
2336
|
+
*/
|
|
2337
|
+
decr = (...args) => this.chain(new DecrCommand(args, this.commandOptions));
|
|
2338
|
+
/**
|
|
2339
|
+
* @see https://redis.io/commands/decrby
|
|
2340
|
+
*/
|
|
2341
|
+
decrby = (...args) => this.chain(new DecrByCommand(args, this.commandOptions));
|
|
2342
|
+
/**
|
|
2343
|
+
* @see https://redis.io/commands/del
|
|
2344
|
+
*/
|
|
2345
|
+
del = (...args) => this.chain(new DelCommand(args, this.commandOptions));
|
|
2346
|
+
/**
|
|
2347
|
+
* @see https://redis.io/commands/echo
|
|
2348
|
+
*/
|
|
2349
|
+
echo = (...args) => this.chain(new EchoCommand(args, this.commandOptions));
|
|
2350
|
+
/**
|
|
2351
|
+
* @see https://redis.io/commands/eval
|
|
2352
|
+
*/
|
|
2353
|
+
eval = (...args) => this.chain(new EvalCommand(args, this.commandOptions));
|
|
2354
|
+
/**
|
|
2355
|
+
* @see https://redis.io/commands/evalsha
|
|
2356
|
+
*/
|
|
2357
|
+
evalsha = (...args) => this.chain(new EvalshaCommand(args, this.commandOptions));
|
|
2358
|
+
/**
|
|
2359
|
+
* @see https://redis.io/commands/exists
|
|
2360
|
+
*/
|
|
2361
|
+
exists = (...args) => this.chain(new ExistsCommand(args, this.commandOptions));
|
|
2362
|
+
/**
|
|
2363
|
+
* @see https://redis.io/commands/expire
|
|
2364
|
+
*/
|
|
2365
|
+
expire = (...args) => this.chain(new ExpireCommand(args, this.commandOptions));
|
|
2366
|
+
/**
|
|
2367
|
+
* @see https://redis.io/commands/expireat
|
|
2368
|
+
*/
|
|
2369
|
+
expireat = (...args) => this.chain(new ExpireAtCommand(args, this.commandOptions));
|
|
2370
|
+
/**
|
|
2371
|
+
* @see https://redis.io/commands/flushall
|
|
2372
|
+
*/
|
|
2373
|
+
flushall = (args) => this.chain(new FlushAllCommand(args, this.commandOptions));
|
|
2374
|
+
/**
|
|
2375
|
+
* @see https://redis.io/commands/flushdb
|
|
2376
|
+
*/
|
|
2377
|
+
flushdb = (...args) => this.chain(new FlushDBCommand(args, this.commandOptions));
|
|
2378
|
+
/**
|
|
2379
|
+
* @see https://redis.io/commands/geoadd
|
|
2380
|
+
*/
|
|
2381
|
+
geoadd = (...args) => this.chain(new GeoAddCommand(args, this.commandOptions));
|
|
2382
|
+
/**
|
|
2383
|
+
* @see https://redis.io/commands/geodist
|
|
2384
|
+
*/
|
|
2385
|
+
geodist = (...args) => this.chain(new GeoDistCommand(args, this.commandOptions));
|
|
2386
|
+
/**
|
|
2387
|
+
* @see https://redis.io/commands/geopos
|
|
2388
|
+
*/
|
|
2389
|
+
geopos = (...args) => this.chain(new GeoPosCommand(args, this.commandOptions));
|
|
2390
|
+
/**
|
|
2391
|
+
* @see https://redis.io/commands/geohash
|
|
2392
|
+
*/
|
|
2393
|
+
geohash = (...args) => this.chain(new GeoHashCommand(args, this.commandOptions));
|
|
2394
|
+
/**
|
|
2395
|
+
* @see https://redis.io/commands/geosearch
|
|
2396
|
+
*/
|
|
2397
|
+
geosearch = (...args) => this.chain(new GeoSearchCommand(args, this.commandOptions));
|
|
2398
|
+
/**
|
|
2399
|
+
* @see https://redis.io/commands/geosearchstore
|
|
2400
|
+
*/
|
|
2401
|
+
geosearchstore = (...args) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions));
|
|
2402
|
+
/**
|
|
2403
|
+
* @see https://redis.io/commands/get
|
|
2404
|
+
*/
|
|
2405
|
+
get = (...args) => this.chain(new GetCommand(args, this.commandOptions));
|
|
2406
|
+
/**
|
|
2407
|
+
* @see https://redis.io/commands/getbit
|
|
2408
|
+
*/
|
|
2409
|
+
getbit = (...args) => this.chain(new GetBitCommand(args, this.commandOptions));
|
|
2410
|
+
/**
|
|
2411
|
+
* @see https://redis.io/commands/getdel
|
|
2412
|
+
*/
|
|
2413
|
+
getdel = (...args) => this.chain(new GetDelCommand(args, this.commandOptions));
|
|
2414
|
+
/**
|
|
2415
|
+
* @see https://redis.io/commands/getrange
|
|
2416
|
+
*/
|
|
2417
|
+
getrange = (...args) => this.chain(new GetRangeCommand(args, this.commandOptions));
|
|
2418
|
+
/**
|
|
2419
|
+
* @see https://redis.io/commands/getset
|
|
2420
|
+
*/
|
|
2421
|
+
getset = (key, value) => this.chain(new GetSetCommand([key, value], this.commandOptions));
|
|
2422
|
+
/**
|
|
2423
|
+
* @see https://redis.io/commands/hdel
|
|
2424
|
+
*/
|
|
2425
|
+
hdel = (...args) => this.chain(new HDelCommand(args, this.commandOptions));
|
|
2426
|
+
/**
|
|
2427
|
+
* @see https://redis.io/commands/hexists
|
|
2428
|
+
*/
|
|
2429
|
+
hexists = (...args) => this.chain(new HExistsCommand(args, this.commandOptions));
|
|
2430
|
+
/**
|
|
2431
|
+
* @see https://redis.io/commands/hget
|
|
2432
|
+
*/
|
|
2433
|
+
hget = (...args) => this.chain(new HGetCommand(args, this.commandOptions));
|
|
2434
|
+
/**
|
|
2435
|
+
* @see https://redis.io/commands/hgetall
|
|
2436
|
+
*/
|
|
2437
|
+
hgetall = (...args) => this.chain(new HGetAllCommand(args, this.commandOptions));
|
|
2438
|
+
/**
|
|
2439
|
+
* @see https://redis.io/commands/hincrby
|
|
2440
|
+
*/
|
|
2441
|
+
hincrby = (...args) => this.chain(new HIncrByCommand(args, this.commandOptions));
|
|
2442
|
+
/**
|
|
2443
|
+
* @see https://redis.io/commands/hincrbyfloat
|
|
2444
|
+
*/
|
|
2445
|
+
hincrbyfloat = (...args) => this.chain(new HIncrByFloatCommand(args, this.commandOptions));
|
|
2446
|
+
/**
|
|
2447
|
+
* @see https://redis.io/commands/hkeys
|
|
2448
|
+
*/
|
|
2449
|
+
hkeys = (...args) => this.chain(new HKeysCommand(args, this.commandOptions));
|
|
2450
|
+
/**
|
|
2451
|
+
* @see https://redis.io/commands/hlen
|
|
2452
|
+
*/
|
|
2453
|
+
hlen = (...args) => this.chain(new HLenCommand(args, this.commandOptions));
|
|
2454
|
+
/**
|
|
2455
|
+
* @see https://redis.io/commands/hmget
|
|
2456
|
+
*/
|
|
2457
|
+
hmget = (...args) => this.chain(new HMGetCommand(args, this.commandOptions));
|
|
2458
|
+
/**
|
|
2459
|
+
* @see https://redis.io/commands/hmset
|
|
2460
|
+
*/
|
|
2461
|
+
hmset = (key, kv) => this.chain(new HMSetCommand([key, kv], this.commandOptions));
|
|
2462
|
+
/**
|
|
2463
|
+
* @see https://redis.io/commands/hrandfield
|
|
2464
|
+
*/
|
|
2465
|
+
hrandfield = (key, count, withValues) => this.chain(new HRandFieldCommand([key, count, withValues], this.commandOptions));
|
|
2466
|
+
/**
|
|
2467
|
+
* @see https://redis.io/commands/hscan
|
|
2468
|
+
*/
|
|
2469
|
+
hscan = (...args) => this.chain(new HScanCommand(args, this.commandOptions));
|
|
2470
|
+
/**
|
|
2471
|
+
* @see https://redis.io/commands/hset
|
|
2472
|
+
*/
|
|
2473
|
+
hset = (key, kv) => this.chain(new HSetCommand([key, kv], this.commandOptions));
|
|
2474
|
+
/**
|
|
2475
|
+
* @see https://redis.io/commands/hsetnx
|
|
2476
|
+
*/
|
|
2477
|
+
hsetnx = (key, field, value) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions));
|
|
2478
|
+
/**
|
|
2479
|
+
* @see https://redis.io/commands/hstrlen
|
|
2480
|
+
*/
|
|
2481
|
+
hstrlen = (...args) => this.chain(new HStrLenCommand(args, this.commandOptions));
|
|
2482
|
+
/**
|
|
2483
|
+
* @see https://redis.io/commands/hvals
|
|
2484
|
+
*/
|
|
2485
|
+
hvals = (...args) => this.chain(new HValsCommand(args, this.commandOptions));
|
|
2486
|
+
/**
|
|
2487
|
+
* @see https://redis.io/commands/incr
|
|
2488
|
+
*/
|
|
2489
|
+
incr = (...args) => this.chain(new IncrCommand(args, this.commandOptions));
|
|
2490
|
+
/**
|
|
2491
|
+
* @see https://redis.io/commands/incrby
|
|
2492
|
+
*/
|
|
2493
|
+
incrby = (...args) => this.chain(new IncrByCommand(args, this.commandOptions));
|
|
2494
|
+
/**
|
|
2495
|
+
* @see https://redis.io/commands/incrbyfloat
|
|
2496
|
+
*/
|
|
2497
|
+
incrbyfloat = (...args) => this.chain(new IncrByFloatCommand(args, this.commandOptions));
|
|
2498
|
+
/**
|
|
2499
|
+
* @see https://redis.io/commands/keys
|
|
2500
|
+
*/
|
|
2501
|
+
keys = (...args) => this.chain(new KeysCommand(args, this.commandOptions));
|
|
2502
|
+
/**
|
|
2503
|
+
* @see https://redis.io/commands/lindex
|
|
2504
|
+
*/
|
|
2505
|
+
lindex = (...args) => this.chain(new LIndexCommand(args, this.commandOptions));
|
|
2506
|
+
/**
|
|
2507
|
+
* @see https://redis.io/commands/linsert
|
|
2508
|
+
*/
|
|
2509
|
+
linsert = (key, direction, pivot, value) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions));
|
|
2510
|
+
/**
|
|
2511
|
+
* @see https://redis.io/commands/llen
|
|
2512
|
+
*/
|
|
2513
|
+
llen = (...args) => this.chain(new LLenCommand(args, this.commandOptions));
|
|
2514
|
+
/**
|
|
2515
|
+
* @see https://redis.io/commands/lmove
|
|
2516
|
+
*/
|
|
2517
|
+
lmove = (...args) => this.chain(new LMoveCommand(args, this.commandOptions));
|
|
2518
|
+
/**
|
|
2519
|
+
* @see https://redis.io/commands/lpop
|
|
2520
|
+
*/
|
|
2521
|
+
lpop = (...args) => this.chain(new LPopCommand(args, this.commandOptions));
|
|
2522
|
+
/**
|
|
2523
|
+
* @see https://redis.io/commands/lmpop
|
|
2524
|
+
*/
|
|
2525
|
+
lmpop = (...args) => this.chain(new LmPopCommand(args, this.commandOptions));
|
|
2526
|
+
/**
|
|
2527
|
+
* @see https://redis.io/commands/lpos
|
|
2528
|
+
*/
|
|
2529
|
+
lpos = (...args) => this.chain(new LPosCommand(args, this.commandOptions));
|
|
2530
|
+
/**
|
|
2531
|
+
* @see https://redis.io/commands/lpush
|
|
2532
|
+
*/
|
|
2533
|
+
lpush = (key, ...elements) => this.chain(new LPushCommand([key, ...elements], this.commandOptions));
|
|
2534
|
+
/**
|
|
2535
|
+
* @see https://redis.io/commands/lpushx
|
|
2536
|
+
*/
|
|
2537
|
+
lpushx = (key, ...elements) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions));
|
|
2538
|
+
/**
|
|
2539
|
+
* @see https://redis.io/commands/lrange
|
|
2540
|
+
*/
|
|
2541
|
+
lrange = (...args) => this.chain(new LRangeCommand(args, this.commandOptions));
|
|
2542
|
+
/**
|
|
2543
|
+
* @see https://redis.io/commands/lrem
|
|
2544
|
+
*/
|
|
2545
|
+
lrem = (key, count, value) => this.chain(new LRemCommand([key, count, value], this.commandOptions));
|
|
2546
|
+
/**
|
|
2547
|
+
* @see https://redis.io/commands/lset
|
|
2548
|
+
*/
|
|
2549
|
+
lset = (key, index, value) => this.chain(new LSetCommand([key, index, value], this.commandOptions));
|
|
2550
|
+
/**
|
|
2551
|
+
* @see https://redis.io/commands/ltrim
|
|
2552
|
+
*/
|
|
2553
|
+
ltrim = (...args) => this.chain(new LTrimCommand(args, this.commandOptions));
|
|
2554
|
+
/**
|
|
2555
|
+
* @see https://redis.io/commands/mget
|
|
2556
|
+
*/
|
|
2557
|
+
mget = (...args) => this.chain(new MGetCommand(args, this.commandOptions));
|
|
2558
|
+
/**
|
|
2559
|
+
* @see https://redis.io/commands/mset
|
|
2560
|
+
*/
|
|
2561
|
+
mset = (kv) => this.chain(new MSetCommand([kv], this.commandOptions));
|
|
2562
|
+
/**
|
|
2563
|
+
* @see https://redis.io/commands/msetnx
|
|
2564
|
+
*/
|
|
2565
|
+
msetnx = (kv) => this.chain(new MSetNXCommand([kv], this.commandOptions));
|
|
2566
|
+
/**
|
|
2567
|
+
* @see https://redis.io/commands/persist
|
|
2568
|
+
*/
|
|
2569
|
+
persist = (...args) => this.chain(new PersistCommand(args, this.commandOptions));
|
|
2570
|
+
/**
|
|
2571
|
+
* @see https://redis.io/commands/pexpire
|
|
2572
|
+
*/
|
|
2573
|
+
pexpire = (...args) => this.chain(new PExpireCommand(args, this.commandOptions));
|
|
2574
|
+
/**
|
|
2575
|
+
* @see https://redis.io/commands/pexpireat
|
|
2576
|
+
*/
|
|
2577
|
+
pexpireat = (...args) => this.chain(new PExpireAtCommand(args, this.commandOptions));
|
|
2578
|
+
/**
|
|
2579
|
+
* @see https://redis.io/commands/pfadd
|
|
2580
|
+
*/
|
|
2581
|
+
pfadd = (...args) => this.chain(new PfAddCommand(args, this.commandOptions));
|
|
2582
|
+
/**
|
|
2583
|
+
* @see https://redis.io/commands/pfcount
|
|
2584
|
+
*/
|
|
2585
|
+
pfcount = (...args) => this.chain(new PfCountCommand(args, this.commandOptions));
|
|
2586
|
+
/**
|
|
2587
|
+
* @see https://redis.io/commands/pfmerge
|
|
2588
|
+
*/
|
|
2589
|
+
pfmerge = (...args) => this.chain(new PfMergeCommand(args, this.commandOptions));
|
|
2590
|
+
/**
|
|
2591
|
+
* @see https://redis.io/commands/ping
|
|
2592
|
+
*/
|
|
2593
|
+
ping = (args) => this.chain(new PingCommand(args, this.commandOptions));
|
|
2594
|
+
/**
|
|
2595
|
+
* @see https://redis.io/commands/psetex
|
|
2596
|
+
*/
|
|
2597
|
+
psetex = (key, ttl, value) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions));
|
|
2598
|
+
/**
|
|
2599
|
+
* @see https://redis.io/commands/pttl
|
|
2600
|
+
*/
|
|
2601
|
+
pttl = (...args) => this.chain(new PTtlCommand(args, this.commandOptions));
|
|
2602
|
+
/**
|
|
2603
|
+
* @see https://redis.io/commands/publish
|
|
2604
|
+
*/
|
|
2605
|
+
publish = (...args) => this.chain(new PublishCommand(args, this.commandOptions));
|
|
2606
|
+
/**
|
|
2607
|
+
* @see https://redis.io/commands/randomkey
|
|
2608
|
+
*/
|
|
2609
|
+
randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
|
|
2610
|
+
/**
|
|
2611
|
+
* @see https://redis.io/commands/rename
|
|
2612
|
+
*/
|
|
2613
|
+
rename = (...args) => this.chain(new RenameCommand(args, this.commandOptions));
|
|
2614
|
+
/**
|
|
2615
|
+
* @see https://redis.io/commands/renamenx
|
|
2616
|
+
*/
|
|
2617
|
+
renamenx = (...args) => this.chain(new RenameNXCommand(args, this.commandOptions));
|
|
2618
|
+
/**
|
|
2619
|
+
* @see https://redis.io/commands/rpop
|
|
2620
|
+
*/
|
|
2621
|
+
rpop = (...args) => this.chain(new RPopCommand(args, this.commandOptions));
|
|
2622
|
+
/**
|
|
2623
|
+
* @see https://redis.io/commands/rpush
|
|
2624
|
+
*/
|
|
2625
|
+
rpush = (key, ...elements) => this.chain(new RPushCommand([key, ...elements], this.commandOptions));
|
|
2626
|
+
/**
|
|
2627
|
+
* @see https://redis.io/commands/rpushx
|
|
2628
|
+
*/
|
|
2629
|
+
rpushx = (key, ...elements) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
|
|
2630
|
+
/**
|
|
2631
|
+
* @see https://redis.io/commands/sadd
|
|
2632
|
+
*/
|
|
2633
|
+
sadd = (key, member, ...members) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions));
|
|
2634
|
+
/**
|
|
2635
|
+
* @see https://redis.io/commands/scan
|
|
2636
|
+
*/
|
|
2637
|
+
scan = (...args) => this.chain(new ScanCommand(args, this.commandOptions));
|
|
2638
|
+
/**
|
|
2639
|
+
* @see https://redis.io/commands/scard
|
|
2640
|
+
*/
|
|
2641
|
+
scard = (...args) => this.chain(new SCardCommand(args, this.commandOptions));
|
|
2642
|
+
/**
|
|
2643
|
+
* @see https://redis.io/commands/script-exists
|
|
2644
|
+
*/
|
|
2645
|
+
scriptExists = (...args) => this.chain(new ScriptExistsCommand(args, this.commandOptions));
|
|
2646
|
+
/**
|
|
2647
|
+
* @see https://redis.io/commands/script-flush
|
|
2648
|
+
*/
|
|
2649
|
+
scriptFlush = (...args) => this.chain(new ScriptFlushCommand(args, this.commandOptions));
|
|
2650
|
+
/**
|
|
2651
|
+
* @see https://redis.io/commands/script-load
|
|
2652
|
+
*/
|
|
2653
|
+
scriptLoad = (...args) => this.chain(new ScriptLoadCommand(args, this.commandOptions));
|
|
2654
|
+
/*)*
|
|
2655
|
+
* @see https://redis.io/commands/sdiff
|
|
2656
|
+
*/
|
|
2657
|
+
sdiff = (...args) => this.chain(new SDiffCommand(args, this.commandOptions));
|
|
2658
|
+
/**
|
|
2659
|
+
* @see https://redis.io/commands/sdiffstore
|
|
2660
|
+
*/
|
|
2661
|
+
sdiffstore = (...args) => this.chain(new SDiffStoreCommand(args, this.commandOptions));
|
|
2662
|
+
/**
|
|
2663
|
+
* @see https://redis.io/commands/set
|
|
2664
|
+
*/
|
|
2665
|
+
set = (key, value, opts) => this.chain(new SetCommand([key, value, opts], this.commandOptions));
|
|
2666
|
+
/**
|
|
2667
|
+
* @see https://redis.io/commands/setbit
|
|
2668
|
+
*/
|
|
2669
|
+
setbit = (...args) => this.chain(new SetBitCommand(args, this.commandOptions));
|
|
2670
|
+
/**
|
|
2671
|
+
* @see https://redis.io/commands/setex
|
|
2672
|
+
*/
|
|
2673
|
+
setex = (key, ttl, value) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions));
|
|
2674
|
+
/**
|
|
2675
|
+
* @see https://redis.io/commands/setnx
|
|
2676
|
+
*/
|
|
2677
|
+
setnx = (key, value) => this.chain(new SetNxCommand([key, value], this.commandOptions));
|
|
2678
|
+
/**
|
|
2679
|
+
* @see https://redis.io/commands/setrange
|
|
2680
|
+
*/
|
|
2681
|
+
setrange = (...args) => this.chain(new SetRangeCommand(args, this.commandOptions));
|
|
2682
|
+
/**
|
|
2683
|
+
* @see https://redis.io/commands/sinter
|
|
2684
|
+
*/
|
|
2685
|
+
sinter = (...args) => this.chain(new SInterCommand(args, this.commandOptions));
|
|
2686
|
+
/**
|
|
2687
|
+
* @see https://redis.io/commands/sinterstore
|
|
2688
|
+
*/
|
|
2689
|
+
sinterstore = (...args) => this.chain(new SInterStoreCommand(args, this.commandOptions));
|
|
2690
|
+
/**
|
|
2691
|
+
* @see https://redis.io/commands/sismember
|
|
2692
|
+
*/
|
|
2693
|
+
sismember = (key, member) => this.chain(new SIsMemberCommand([key, member], this.commandOptions));
|
|
2694
|
+
/**
|
|
2695
|
+
* @see https://redis.io/commands/smembers
|
|
2696
|
+
*/
|
|
2697
|
+
smembers = (...args) => this.chain(new SMembersCommand(args, this.commandOptions));
|
|
2698
|
+
/**
|
|
2699
|
+
* @see https://redis.io/commands/smismember
|
|
2700
|
+
*/
|
|
2701
|
+
smismember = (key, members) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions));
|
|
2702
|
+
/**
|
|
2703
|
+
* @see https://redis.io/commands/smove
|
|
2704
|
+
*/
|
|
2705
|
+
smove = (source, destination, member) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions));
|
|
2706
|
+
/**
|
|
2707
|
+
* @see https://redis.io/commands/spop
|
|
2708
|
+
*/
|
|
2709
|
+
spop = (...args) => this.chain(new SPopCommand(args, this.commandOptions));
|
|
2710
|
+
/**
|
|
2711
|
+
* @see https://redis.io/commands/srandmember
|
|
2712
|
+
*/
|
|
2713
|
+
srandmember = (...args) => this.chain(new SRandMemberCommand(args, this.commandOptions));
|
|
2714
|
+
/**
|
|
2715
|
+
* @see https://redis.io/commands/srem
|
|
2716
|
+
*/
|
|
2717
|
+
srem = (key, ...members) => this.chain(new SRemCommand([key, ...members], this.commandOptions));
|
|
2718
|
+
/**
|
|
2719
|
+
* @see https://redis.io/commands/sscan
|
|
2720
|
+
*/
|
|
2721
|
+
sscan = (...args) => this.chain(new SScanCommand(args, this.commandOptions));
|
|
2722
|
+
/**
|
|
2723
|
+
* @see https://redis.io/commands/strlen
|
|
2724
|
+
*/
|
|
2725
|
+
strlen = (...args) => this.chain(new StrLenCommand(args, this.commandOptions));
|
|
2726
|
+
/**
|
|
2727
|
+
* @see https://redis.io/commands/sunion
|
|
2728
|
+
*/
|
|
2729
|
+
sunion = (...args) => this.chain(new SUnionCommand(args, this.commandOptions));
|
|
2730
|
+
/**
|
|
2731
|
+
* @see https://redis.io/commands/sunionstore
|
|
2732
|
+
*/
|
|
2733
|
+
sunionstore = (...args) => this.chain(new SUnionStoreCommand(args, this.commandOptions));
|
|
2734
|
+
/**
|
|
2735
|
+
* @see https://redis.io/commands/time
|
|
2736
|
+
*/
|
|
2737
|
+
time = () => this.chain(new TimeCommand(this.commandOptions));
|
|
2738
|
+
/**
|
|
2739
|
+
* @see https://redis.io/commands/touch
|
|
2740
|
+
*/
|
|
2741
|
+
touch = (...args) => this.chain(new TouchCommand(args, this.commandOptions));
|
|
2742
|
+
/**
|
|
2743
|
+
* @see https://redis.io/commands/ttl
|
|
2744
|
+
*/
|
|
2745
|
+
ttl = (...args) => this.chain(new TtlCommand(args, this.commandOptions));
|
|
2746
|
+
/**
|
|
2747
|
+
* @see https://redis.io/commands/type
|
|
2748
|
+
*/
|
|
2749
|
+
type = (...args) => this.chain(new TypeCommand(args, this.commandOptions));
|
|
2750
|
+
/**
|
|
2751
|
+
* @see https://redis.io/commands/unlink
|
|
2752
|
+
*/
|
|
2753
|
+
unlink = (...args) => this.chain(new UnlinkCommand(args, this.commandOptions));
|
|
2754
|
+
/**
|
|
2755
|
+
* @see https://redis.io/commands/zadd
|
|
2756
|
+
*/
|
|
2757
|
+
zadd = (...args) => {
|
|
2758
|
+
if ("score" in args[1]) {
|
|
2759
|
+
return this.chain(
|
|
2760
|
+
new ZAddCommand([args[0], args[1], ...args.slice(2)], this.commandOptions)
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
return this.chain(
|
|
2764
|
+
new ZAddCommand(
|
|
2765
|
+
[args[0], args[1], ...args.slice(2)],
|
|
2766
|
+
this.commandOptions
|
|
2767
|
+
)
|
|
2768
|
+
);
|
|
2769
|
+
};
|
|
2770
|
+
/**
|
|
2771
|
+
* @see https://redis.io/commands/xadd
|
|
2772
|
+
*/
|
|
2773
|
+
xadd = (...args) => this.chain(new XAddCommand(args, this.commandOptions));
|
|
2774
|
+
/**
|
|
2775
|
+
* @see https://redis.io/commands/xack
|
|
2776
|
+
*/
|
|
2777
|
+
xack = (...args) => this.chain(new XAckCommand(args, this.commandOptions));
|
|
2778
|
+
/**
|
|
2779
|
+
* @see https://redis.io/commands/xdel
|
|
2780
|
+
*/
|
|
2781
|
+
xdel = (...args) => this.chain(new XDelCommand(args, this.commandOptions));
|
|
2782
|
+
/**
|
|
2783
|
+
* @see https://redis.io/commands/xgroup
|
|
2784
|
+
*/
|
|
2785
|
+
xgroup = (...args) => this.chain(new XGroupCommand(args, this.commandOptions));
|
|
2786
|
+
/**
|
|
2787
|
+
* @see https://redis.io/commands/xread
|
|
2788
|
+
*/
|
|
2789
|
+
xread = (...args) => this.chain(new XReadCommand(args, this.commandOptions));
|
|
2790
|
+
/**
|
|
2791
|
+
* @see https://redis.io/commands/xreadgroup
|
|
2792
|
+
*/
|
|
2793
|
+
xreadgroup = (...args) => this.chain(new XReadGroupCommand(args, this.commandOptions));
|
|
2794
|
+
/**
|
|
2795
|
+
* @see https://redis.io/commands/xinfo
|
|
2796
|
+
*/
|
|
2797
|
+
xinfo = (...args) => this.chain(new XInfoCommand(args, this.commandOptions));
|
|
2798
|
+
/**
|
|
2799
|
+
* @see https://redis.io/commands/xlen
|
|
2800
|
+
*/
|
|
2801
|
+
xlen = (...args) => this.chain(new XLenCommand(args, this.commandOptions));
|
|
2802
|
+
/**
|
|
2803
|
+
* @see https://redis.io/commands/xpending
|
|
2804
|
+
*/
|
|
2805
|
+
xpending = (...args) => this.chain(new XPendingCommand(args, this.commandOptions));
|
|
2806
|
+
/**
|
|
2807
|
+
* @see https://redis.io/commands/xclaim
|
|
2808
|
+
*/
|
|
2809
|
+
xclaim = (...args) => this.chain(new XClaimCommand(args, this.commandOptions));
|
|
2810
|
+
/**
|
|
2811
|
+
* @see https://redis.io/commands/xautoclaim
|
|
2812
|
+
*/
|
|
2813
|
+
xautoclaim = (...args) => this.chain(new XAutoClaim(args, this.commandOptions));
|
|
2814
|
+
/**
|
|
2815
|
+
* @see https://redis.io/commands/xtrim
|
|
2816
|
+
*/
|
|
2817
|
+
xtrim = (...args) => this.chain(new XTrimCommand(args, this.commandOptions));
|
|
2818
|
+
/**
|
|
2819
|
+
* @see https://redis.io/commands/xrange
|
|
2820
|
+
*/
|
|
2821
|
+
xrange = (...args) => this.chain(new XRangeCommand(args, this.commandOptions));
|
|
2822
|
+
/**
|
|
2823
|
+
* @see https://redis.io/commands/xrevrange
|
|
2824
|
+
*/
|
|
2825
|
+
xrevrange = (...args) => this.chain(new XRevRangeCommand(args, this.commandOptions));
|
|
2826
|
+
/**
|
|
2827
|
+
* @see https://redis.io/commands/zcard
|
|
2828
|
+
*/
|
|
2829
|
+
zcard = (...args) => this.chain(new ZCardCommand(args, this.commandOptions));
|
|
2830
|
+
/**
|
|
2831
|
+
* @see https://redis.io/commands/zcount
|
|
2832
|
+
*/
|
|
2833
|
+
zcount = (...args) => this.chain(new ZCountCommand(args, this.commandOptions));
|
|
2834
|
+
/**
|
|
2835
|
+
* @see https://redis.io/commands/zincrby
|
|
2836
|
+
*/
|
|
2837
|
+
zincrby = (key, increment, member) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions));
|
|
2838
|
+
/**
|
|
2839
|
+
* @see https://redis.io/commands/zinterstore
|
|
2840
|
+
*/
|
|
2841
|
+
zinterstore = (...args) => this.chain(new ZInterStoreCommand(args, this.commandOptions));
|
|
2842
|
+
/**
|
|
2843
|
+
* @see https://redis.io/commands/zlexcount
|
|
2844
|
+
*/
|
|
2845
|
+
zlexcount = (...args) => this.chain(new ZLexCountCommand(args, this.commandOptions));
|
|
2846
|
+
/**
|
|
2847
|
+
* @see https://redis.io/commands/zmscore
|
|
2848
|
+
*/
|
|
2849
|
+
zmscore = (...args) => this.chain(new ZMScoreCommand(args, this.commandOptions));
|
|
2850
|
+
/**
|
|
2851
|
+
* @see https://redis.io/commands/zpopmax
|
|
2852
|
+
*/
|
|
2853
|
+
zpopmax = (...args) => this.chain(new ZPopMaxCommand(args, this.commandOptions));
|
|
2854
|
+
/**
|
|
2855
|
+
* @see https://redis.io/commands/zpopmin
|
|
2856
|
+
*/
|
|
2857
|
+
zpopmin = (...args) => this.chain(new ZPopMinCommand(args, this.commandOptions));
|
|
2858
|
+
/**
|
|
2859
|
+
* @see https://redis.io/commands/zrange
|
|
2860
|
+
*/
|
|
2861
|
+
zrange = (...args) => this.chain(new ZRangeCommand(args, this.commandOptions));
|
|
2862
|
+
/**
|
|
2863
|
+
* @see https://redis.io/commands/zrank
|
|
2864
|
+
*/
|
|
2865
|
+
zrank = (key, member) => this.chain(new ZRankCommand([key, member], this.commandOptions));
|
|
2866
|
+
/**
|
|
2867
|
+
* @see https://redis.io/commands/zrem
|
|
2868
|
+
*/
|
|
2869
|
+
zrem = (key, ...members) => this.chain(new ZRemCommand([key, ...members], this.commandOptions));
|
|
2870
|
+
/**
|
|
2871
|
+
* @see https://redis.io/commands/zremrangebylex
|
|
2872
|
+
*/
|
|
2873
|
+
zremrangebylex = (...args) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
|
|
2874
|
+
/**
|
|
2875
|
+
* @see https://redis.io/commands/zremrangebyrank
|
|
2876
|
+
*/
|
|
2877
|
+
zremrangebyrank = (...args) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
|
|
2878
|
+
/**
|
|
2879
|
+
* @see https://redis.io/commands/zremrangebyscore
|
|
2880
|
+
*/
|
|
2881
|
+
zremrangebyscore = (...args) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
|
|
2882
|
+
/**
|
|
2883
|
+
* @see https://redis.io/commands/zrevrank
|
|
2884
|
+
*/
|
|
2885
|
+
zrevrank = (key, member) => this.chain(new ZRevRankCommand([key, member], this.commandOptions));
|
|
2886
|
+
/**
|
|
2887
|
+
* @see https://redis.io/commands/zscan
|
|
2888
|
+
*/
|
|
2889
|
+
zscan = (...args) => this.chain(new ZScanCommand(args, this.commandOptions));
|
|
2890
|
+
/**
|
|
2891
|
+
* @see https://redis.io/commands/zscore
|
|
2892
|
+
*/
|
|
2893
|
+
zscore = (key, member) => this.chain(new ZScoreCommand([key, member], this.commandOptions));
|
|
2894
|
+
/**
|
|
2895
|
+
* @see https://redis.io/commands/zunionstore
|
|
2896
|
+
*/
|
|
2897
|
+
zunionstore = (...args) => this.chain(new ZUnionStoreCommand(args, this.commandOptions));
|
|
2898
|
+
/**
|
|
2899
|
+
* @see https://redis.io/commands/zunion
|
|
2900
|
+
*/
|
|
2901
|
+
zunion = (...args) => this.chain(new ZUnionCommand(args, this.commandOptions));
|
|
2902
|
+
/**
|
|
2903
|
+
* @see https://redis.io/commands/?group=json
|
|
2904
|
+
*/
|
|
2905
|
+
get json() {
|
|
2906
|
+
return {
|
|
2907
|
+
/**
|
|
2908
|
+
* @see https://redis.io/commands/json.arrappend
|
|
2909
|
+
*/
|
|
2910
|
+
arrappend: (...args) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
|
|
2911
|
+
/**
|
|
2912
|
+
* @see https://redis.io/commands/json.arrindex
|
|
2913
|
+
*/
|
|
2914
|
+
arrindex: (...args) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
|
|
2915
|
+
/**
|
|
2916
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
2917
|
+
*/
|
|
2918
|
+
arrinsert: (...args) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
|
|
2919
|
+
/**
|
|
2920
|
+
* @see https://redis.io/commands/json.arrlen
|
|
2921
|
+
*/
|
|
2922
|
+
arrlen: (...args) => this.chain(new JsonArrLenCommand(args, this.commandOptions)),
|
|
2923
|
+
/**
|
|
2924
|
+
* @see https://redis.io/commands/json.arrpop
|
|
2925
|
+
*/
|
|
2926
|
+
arrpop: (...args) => this.chain(new JsonArrPopCommand(args, this.commandOptions)),
|
|
2927
|
+
/**
|
|
2928
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
2929
|
+
*/
|
|
2930
|
+
arrtrim: (...args) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
|
|
2931
|
+
/**
|
|
2932
|
+
* @see https://redis.io/commands/json.clear
|
|
2933
|
+
*/
|
|
2934
|
+
clear: (...args) => this.chain(new JsonClearCommand(args, this.commandOptions)),
|
|
2935
|
+
/**
|
|
2936
|
+
* @see https://redis.io/commands/json.del
|
|
2937
|
+
*/
|
|
2938
|
+
del: (...args) => this.chain(new JsonDelCommand(args, this.commandOptions)),
|
|
2939
|
+
/**
|
|
2940
|
+
* @see https://redis.io/commands/json.forget
|
|
2941
|
+
*/
|
|
2942
|
+
forget: (...args) => this.chain(new JsonForgetCommand(args, this.commandOptions)),
|
|
2943
|
+
/**
|
|
2944
|
+
* @see https://redis.io/commands/json.get
|
|
2945
|
+
*/
|
|
2946
|
+
get: (...args) => this.chain(new JsonGetCommand(args, this.commandOptions)),
|
|
2947
|
+
/**
|
|
2948
|
+
* @see https://redis.io/commands/json.mget
|
|
2949
|
+
*/
|
|
2950
|
+
mget: (...args) => this.chain(new JsonMGetCommand(args, this.commandOptions)),
|
|
2951
|
+
/**
|
|
2952
|
+
* @see https://redis.io/commands/json.mset
|
|
2953
|
+
*/
|
|
2954
|
+
mset: (...args) => this.chain(new JsonMSetCommand(args, this.commandOptions)),
|
|
2955
|
+
/**
|
|
2956
|
+
* @see https://redis.io/commands/json.numincrby
|
|
2957
|
+
*/
|
|
2958
|
+
numincrby: (...args) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
|
|
2959
|
+
/**
|
|
2960
|
+
* @see https://redis.io/commands/json.nummultby
|
|
2961
|
+
*/
|
|
2962
|
+
nummultby: (...args) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
|
|
2963
|
+
/**
|
|
2964
|
+
* @see https://redis.io/commands/json.objkeys
|
|
2965
|
+
*/
|
|
2966
|
+
objkeys: (...args) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
|
|
2967
|
+
/**
|
|
2968
|
+
* @see https://redis.io/commands/json.objlen
|
|
2969
|
+
*/
|
|
2970
|
+
objlen: (...args) => this.chain(new JsonObjLenCommand(args, this.commandOptions)),
|
|
2971
|
+
/**
|
|
2972
|
+
* @see https://redis.io/commands/json.resp
|
|
2973
|
+
*/
|
|
2974
|
+
resp: (...args) => this.chain(new JsonRespCommand(args, this.commandOptions)),
|
|
2975
|
+
/**
|
|
2976
|
+
* @see https://redis.io/commands/json.set
|
|
2977
|
+
*/
|
|
2978
|
+
set: (...args) => this.chain(new JsonSetCommand(args, this.commandOptions)),
|
|
2979
|
+
/**
|
|
2980
|
+
* @see https://redis.io/commands/json.strappend
|
|
2981
|
+
*/
|
|
2982
|
+
strappend: (...args) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
|
|
2983
|
+
/**
|
|
2984
|
+
* @see https://redis.io/commands/json.strlen
|
|
2985
|
+
*/
|
|
2986
|
+
strlen: (...args) => this.chain(new JsonStrLenCommand(args, this.commandOptions)),
|
|
2987
|
+
/**
|
|
2988
|
+
* @see https://redis.io/commands/json.toggle
|
|
2989
|
+
*/
|
|
2990
|
+
toggle: (...args) => this.chain(new JsonToggleCommand(args, this.commandOptions)),
|
|
2991
|
+
/**
|
|
2992
|
+
* @see https://redis.io/commands/json.type
|
|
2993
|
+
*/
|
|
2994
|
+
type: (...args) => this.chain(new JsonTypeCommand(args, this.commandOptions))
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
};
|
|
2998
|
+
|
|
2999
|
+
// pkg/script.ts
|
|
3000
|
+
var import_enc_hex = __toESM(require("crypto-js/enc-hex.js"));
|
|
3001
|
+
var import_sha1 = __toESM(require("crypto-js/sha1.js"));
|
|
3002
|
+
var Script = class {
|
|
3003
|
+
script;
|
|
3004
|
+
sha1;
|
|
3005
|
+
redis;
|
|
3006
|
+
constructor(redis, script) {
|
|
3007
|
+
this.redis = redis;
|
|
3008
|
+
this.sha1 = this.digest(script);
|
|
3009
|
+
this.script = script;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* Send an `EVAL` command to redis.
|
|
3013
|
+
*/
|
|
3014
|
+
async eval(keys, args) {
|
|
3015
|
+
return await this.redis.eval(this.script, keys, args);
|
|
3016
|
+
}
|
|
3017
|
+
/**
|
|
3018
|
+
* Calculates the sha1 hash of the script and then calls `EVALSHA`.
|
|
3019
|
+
*/
|
|
3020
|
+
async evalsha(keys, args) {
|
|
3021
|
+
return await this.redis.evalsha(this.sha1, keys, args);
|
|
3022
|
+
}
|
|
3023
|
+
/**
|
|
3024
|
+
* Optimistically try to run `EVALSHA` first.
|
|
3025
|
+
* If the script is not loaded in redis, it will fall back and try again with `EVAL`.
|
|
3026
|
+
*
|
|
3027
|
+
* Following calls will be able to use the cached script
|
|
3028
|
+
*/
|
|
3029
|
+
async exec(keys, args) {
|
|
3030
|
+
const res = await this.redis.evalsha(this.sha1, keys, args).catch(async (error) => {
|
|
3031
|
+
if (error instanceof Error && error.message.toLowerCase().includes("noscript")) {
|
|
3032
|
+
return await this.redis.eval(this.script, keys, args);
|
|
3033
|
+
}
|
|
3034
|
+
throw error;
|
|
3035
|
+
});
|
|
3036
|
+
return res;
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* Compute the sha1 hash of the script and return its hex representation.
|
|
3040
|
+
*/
|
|
3041
|
+
digest(s) {
|
|
3042
|
+
return import_enc_hex.default.stringify((0, import_sha1.default)(s));
|
|
3043
|
+
}
|
|
3044
|
+
};
|
|
3045
|
+
|
|
3046
|
+
// pkg/redis.ts
|
|
3047
|
+
var Redis = class {
|
|
3048
|
+
client;
|
|
3049
|
+
opts;
|
|
3050
|
+
enableTelemetry;
|
|
3051
|
+
enableAutoPipelining;
|
|
3052
|
+
/**
|
|
3053
|
+
* Create a new redis client
|
|
3054
|
+
*
|
|
3055
|
+
* @example
|
|
3056
|
+
* ```typescript
|
|
3057
|
+
* const redis = new Redis({
|
|
3058
|
+
* url: "<UPSTASH_REDIS_REST_URL>",
|
|
3059
|
+
* token: "<UPSTASH_REDIS_REST_TOKEN>",
|
|
3060
|
+
* });
|
|
3061
|
+
* ```
|
|
3062
|
+
*/
|
|
3063
|
+
constructor(client, opts) {
|
|
3064
|
+
this.client = client;
|
|
3065
|
+
this.opts = opts;
|
|
3066
|
+
this.enableTelemetry = opts?.enableTelemetry ?? true;
|
|
3067
|
+
if (opts?.readYourWrites === false) {
|
|
3068
|
+
this.client.readYourWrites = false;
|
|
3069
|
+
}
|
|
3070
|
+
this.enableAutoPipelining = opts?.enableAutoPipelining ?? true;
|
|
3071
|
+
}
|
|
3072
|
+
get readYourWritesSyncToken() {
|
|
3073
|
+
return this.client.upstashSyncToken;
|
|
3074
|
+
}
|
|
3075
|
+
set readYourWritesSyncToken(session) {
|
|
3076
|
+
this.client.upstashSyncToken = session;
|
|
3077
|
+
}
|
|
3078
|
+
get json() {
|
|
3079
|
+
return {
|
|
3080
|
+
/**
|
|
3081
|
+
* @see https://redis.io/commands/json.arrappend
|
|
3082
|
+
*/
|
|
3083
|
+
arrappend: (...args) => new JsonArrAppendCommand(args, this.opts).exec(this.client),
|
|
3084
|
+
/**
|
|
3085
|
+
* @see https://redis.io/commands/json.arrindex
|
|
3086
|
+
*/
|
|
3087
|
+
arrindex: (...args) => new JsonArrIndexCommand(args, this.opts).exec(this.client),
|
|
3088
|
+
/**
|
|
3089
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
3090
|
+
*/
|
|
3091
|
+
arrinsert: (...args) => new JsonArrInsertCommand(args, this.opts).exec(this.client),
|
|
3092
|
+
/**
|
|
3093
|
+
* @see https://redis.io/commands/json.arrlen
|
|
3094
|
+
*/
|
|
3095
|
+
arrlen: (...args) => new JsonArrLenCommand(args, this.opts).exec(this.client),
|
|
3096
|
+
/**
|
|
3097
|
+
* @see https://redis.io/commands/json.arrpop
|
|
3098
|
+
*/
|
|
3099
|
+
arrpop: (...args) => new JsonArrPopCommand(args, this.opts).exec(this.client),
|
|
3100
|
+
/**
|
|
3101
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
3102
|
+
*/
|
|
3103
|
+
arrtrim: (...args) => new JsonArrTrimCommand(args, this.opts).exec(this.client),
|
|
3104
|
+
/**
|
|
3105
|
+
* @see https://redis.io/commands/json.clear
|
|
3106
|
+
*/
|
|
3107
|
+
clear: (...args) => new JsonClearCommand(args, this.opts).exec(this.client),
|
|
3108
|
+
/**
|
|
3109
|
+
* @see https://redis.io/commands/json.del
|
|
3110
|
+
*/
|
|
3111
|
+
del: (...args) => new JsonDelCommand(args, this.opts).exec(this.client),
|
|
3112
|
+
/**
|
|
3113
|
+
* @see https://redis.io/commands/json.forget
|
|
3114
|
+
*/
|
|
3115
|
+
forget: (...args) => new JsonForgetCommand(args, this.opts).exec(this.client),
|
|
3116
|
+
/**
|
|
3117
|
+
* @see https://redis.io/commands/json.get
|
|
3118
|
+
*/
|
|
3119
|
+
get: (...args) => new JsonGetCommand(args, this.opts).exec(this.client),
|
|
3120
|
+
/**
|
|
3121
|
+
* @see https://redis.io/commands/json.mget
|
|
3122
|
+
*/
|
|
3123
|
+
mget: (...args) => new JsonMGetCommand(args, this.opts).exec(this.client),
|
|
3124
|
+
/**
|
|
3125
|
+
* @see https://redis.io/commands/json.mset
|
|
3126
|
+
*/
|
|
3127
|
+
mset: (...args) => new JsonMSetCommand(args, this.opts).exec(this.client),
|
|
3128
|
+
/**
|
|
3129
|
+
* @see https://redis.io/commands/json.numincrby
|
|
3130
|
+
*/
|
|
3131
|
+
numincrby: (...args) => new JsonNumIncrByCommand(args, this.opts).exec(this.client),
|
|
3132
|
+
/**
|
|
3133
|
+
* @see https://redis.io/commands/json.nummultby
|
|
3134
|
+
*/
|
|
3135
|
+
nummultby: (...args) => new JsonNumMultByCommand(args, this.opts).exec(this.client),
|
|
3136
|
+
/**
|
|
3137
|
+
* @see https://redis.io/commands/json.objkeys
|
|
3138
|
+
*/
|
|
3139
|
+
objkeys: (...args) => new JsonObjKeysCommand(args, this.opts).exec(this.client),
|
|
3140
|
+
/**
|
|
3141
|
+
* @see https://redis.io/commands/json.objlen
|
|
3142
|
+
*/
|
|
3143
|
+
objlen: (...args) => new JsonObjLenCommand(args, this.opts).exec(this.client),
|
|
3144
|
+
/**
|
|
3145
|
+
* @see https://redis.io/commands/json.resp
|
|
3146
|
+
*/
|
|
3147
|
+
resp: (...args) => new JsonRespCommand(args, this.opts).exec(this.client),
|
|
3148
|
+
/**
|
|
3149
|
+
* @see https://redis.io/commands/json.set
|
|
3150
|
+
*/
|
|
3151
|
+
set: (...args) => new JsonSetCommand(args, this.opts).exec(this.client),
|
|
3152
|
+
/**
|
|
3153
|
+
* @see https://redis.io/commands/json.strappend
|
|
3154
|
+
*/
|
|
3155
|
+
strappend: (...args) => new JsonStrAppendCommand(args, this.opts).exec(this.client),
|
|
3156
|
+
/**
|
|
3157
|
+
* @see https://redis.io/commands/json.strlen
|
|
3158
|
+
*/
|
|
3159
|
+
strlen: (...args) => new JsonStrLenCommand(args, this.opts).exec(this.client),
|
|
3160
|
+
/**
|
|
3161
|
+
* @see https://redis.io/commands/json.toggle
|
|
3162
|
+
*/
|
|
3163
|
+
toggle: (...args) => new JsonToggleCommand(args, this.opts).exec(this.client),
|
|
3164
|
+
/**
|
|
3165
|
+
* @see https://redis.io/commands/json.type
|
|
3166
|
+
*/
|
|
3167
|
+
type: (...args) => new JsonTypeCommand(args, this.opts).exec(this.client)
|
|
3168
|
+
};
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Wrap a new middleware around the HTTP client.
|
|
3172
|
+
*/
|
|
3173
|
+
use = (middleware) => {
|
|
3174
|
+
const makeRequest = this.client.request.bind(this.client);
|
|
3175
|
+
this.client.request = (req) => middleware(req, makeRequest);
|
|
3176
|
+
};
|
|
3177
|
+
/**
|
|
3178
|
+
* Technically this is not private, we can hide it from intellisense by doing this
|
|
3179
|
+
*/
|
|
3180
|
+
addTelemetry = (telemetry) => {
|
|
3181
|
+
if (!this.enableTelemetry) {
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
try {
|
|
3185
|
+
this.client.mergeTelemetry(telemetry);
|
|
3186
|
+
} catch {
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
3189
|
+
createScript(script) {
|
|
3190
|
+
return new Script(this, script);
|
|
3191
|
+
}
|
|
3192
|
+
/**
|
|
3193
|
+
* Create a new pipeline that allows you to send requests in bulk.
|
|
3194
|
+
*
|
|
3195
|
+
* @see {@link Pipeline}
|
|
3196
|
+
*/
|
|
3197
|
+
pipeline = () => new Pipeline({
|
|
3198
|
+
client: this.client,
|
|
3199
|
+
commandOptions: this.opts,
|
|
3200
|
+
multiExec: false
|
|
3201
|
+
});
|
|
3202
|
+
autoPipeline = () => {
|
|
3203
|
+
return createAutoPipelineProxy(this);
|
|
3204
|
+
};
|
|
3205
|
+
/**
|
|
3206
|
+
* Create a new transaction to allow executing multiple steps atomically.
|
|
3207
|
+
*
|
|
3208
|
+
* All the commands in a transaction are serialized and executed sequentially. A request sent by
|
|
3209
|
+
* another client will never be served in the middle of the execution of a Redis Transaction. This
|
|
3210
|
+
* guarantees that the commands are executed as a single isolated operation.
|
|
3211
|
+
*
|
|
3212
|
+
* @see {@link Pipeline}
|
|
3213
|
+
*/
|
|
3214
|
+
multi = () => new Pipeline({
|
|
3215
|
+
client: this.client,
|
|
3216
|
+
commandOptions: this.opts,
|
|
3217
|
+
multiExec: true
|
|
3218
|
+
});
|
|
3219
|
+
/**
|
|
3220
|
+
* Returns an instance that can be used to execute `BITFIELD` commands on one key.
|
|
3221
|
+
*
|
|
3222
|
+
* @example
|
|
3223
|
+
* ```typescript
|
|
3224
|
+
* redis.set("mykey", 0);
|
|
3225
|
+
* const result = await redis.bitfield("mykey")
|
|
3226
|
+
* .set("u4", 0, 16)
|
|
3227
|
+
* .incr("u4", "#1", 1)
|
|
3228
|
+
* .exec();
|
|
3229
|
+
* console.log(result); // [0, 1]
|
|
3230
|
+
* ```
|
|
3231
|
+
*
|
|
3232
|
+
* @see https://redis.io/commands/bitfield
|
|
3233
|
+
*/
|
|
3234
|
+
bitfield = (...args) => new BitFieldCommand(args, this.client, this.opts);
|
|
3235
|
+
/**
|
|
3236
|
+
* @see https://redis.io/commands/append
|
|
3237
|
+
*/
|
|
3238
|
+
append = (...args) => new AppendCommand(args, this.opts).exec(this.client);
|
|
3239
|
+
/**
|
|
3240
|
+
* @see https://redis.io/commands/bitcount
|
|
3241
|
+
*/
|
|
3242
|
+
bitcount = (...args) => new BitCountCommand(args, this.opts).exec(this.client);
|
|
3243
|
+
/**
|
|
3244
|
+
* @see https://redis.io/commands/bitop
|
|
3245
|
+
*/
|
|
3246
|
+
bitop = (op, destinationKey, sourceKey, ...sourceKeys) => new BitOpCommand([op, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
|
|
3247
|
+
this.client
|
|
3248
|
+
);
|
|
3249
|
+
/**
|
|
3250
|
+
* @see https://redis.io/commands/bitpos
|
|
3251
|
+
*/
|
|
3252
|
+
bitpos = (...args) => new BitPosCommand(args, this.opts).exec(this.client);
|
|
3253
|
+
/**
|
|
3254
|
+
* @see https://redis.io/commands/copy
|
|
3255
|
+
*/
|
|
3256
|
+
copy = (...args) => new CopyCommand(args, this.opts).exec(this.client);
|
|
3257
|
+
/**
|
|
3258
|
+
* @see https://redis.io/commands/dbsize
|
|
3259
|
+
*/
|
|
3260
|
+
dbsize = () => new DBSizeCommand(this.opts).exec(this.client);
|
|
3261
|
+
/**
|
|
3262
|
+
* @see https://redis.io/commands/decr
|
|
3263
|
+
*/
|
|
3264
|
+
decr = (...args) => new DecrCommand(args, this.opts).exec(this.client);
|
|
3265
|
+
/**
|
|
3266
|
+
* @see https://redis.io/commands/decrby
|
|
3267
|
+
*/
|
|
3268
|
+
decrby = (...args) => new DecrByCommand(args, this.opts).exec(this.client);
|
|
3269
|
+
/**
|
|
3270
|
+
* @see https://redis.io/commands/del
|
|
3271
|
+
*/
|
|
3272
|
+
del = (...args) => new DelCommand(args, this.opts).exec(this.client);
|
|
3273
|
+
/**
|
|
3274
|
+
* @see https://redis.io/commands/echo
|
|
3275
|
+
*/
|
|
3276
|
+
echo = (...args) => new EchoCommand(args, this.opts).exec(this.client);
|
|
3277
|
+
/**
|
|
3278
|
+
* @see https://redis.io/commands/eval
|
|
3279
|
+
*/
|
|
3280
|
+
eval = (...args) => new EvalCommand(args, this.opts).exec(this.client);
|
|
3281
|
+
/**
|
|
3282
|
+
* @see https://redis.io/commands/evalsha
|
|
3283
|
+
*/
|
|
3284
|
+
evalsha = (...args) => new EvalshaCommand(args, this.opts).exec(this.client);
|
|
3285
|
+
/**
|
|
3286
|
+
* @see https://redis.io/commands/exists
|
|
3287
|
+
*/
|
|
3288
|
+
exists = (...args) => new ExistsCommand(args, this.opts).exec(this.client);
|
|
3289
|
+
/**
|
|
3290
|
+
* @see https://redis.io/commands/expire
|
|
3291
|
+
*/
|
|
3292
|
+
expire = (...args) => new ExpireCommand(args, this.opts).exec(this.client);
|
|
3293
|
+
/**
|
|
3294
|
+
* @see https://redis.io/commands/expireat
|
|
3295
|
+
*/
|
|
3296
|
+
expireat = (...args) => new ExpireAtCommand(args, this.opts).exec(this.client);
|
|
3297
|
+
/**
|
|
3298
|
+
* @see https://redis.io/commands/flushall
|
|
3299
|
+
*/
|
|
3300
|
+
flushall = (args) => new FlushAllCommand(args, this.opts).exec(this.client);
|
|
3301
|
+
/**
|
|
3302
|
+
* @see https://redis.io/commands/flushdb
|
|
3303
|
+
*/
|
|
3304
|
+
flushdb = (...args) => new FlushDBCommand(args, this.opts).exec(this.client);
|
|
3305
|
+
/**
|
|
3306
|
+
* @see https://redis.io/commands/geoadd
|
|
3307
|
+
*/
|
|
3308
|
+
geoadd = (...args) => new GeoAddCommand(args, this.opts).exec(this.client);
|
|
3309
|
+
/**
|
|
3310
|
+
* @see https://redis.io/commands/geopos
|
|
3311
|
+
*/
|
|
3312
|
+
geopos = (...args) => new GeoPosCommand(args, this.opts).exec(this.client);
|
|
3313
|
+
/**
|
|
3314
|
+
* @see https://redis.io/commands/geodist
|
|
3315
|
+
*/
|
|
3316
|
+
geodist = (...args) => new GeoDistCommand(args, this.opts).exec(this.client);
|
|
3317
|
+
/**
|
|
3318
|
+
* @see https://redis.io/commands/geohash
|
|
3319
|
+
*/
|
|
3320
|
+
geohash = (...args) => new GeoHashCommand(args, this.opts).exec(this.client);
|
|
3321
|
+
/**
|
|
3322
|
+
* @see https://redis.io/commands/geosearch
|
|
3323
|
+
*/
|
|
3324
|
+
geosearch = (...args) => new GeoSearchCommand(args, this.opts).exec(this.client);
|
|
3325
|
+
/**
|
|
3326
|
+
* @see https://redis.io/commands/geosearchstore
|
|
3327
|
+
*/
|
|
3328
|
+
geosearchstore = (...args) => new GeoSearchStoreCommand(args, this.opts).exec(this.client);
|
|
3329
|
+
/**
|
|
3330
|
+
* @see https://redis.io/commands/get
|
|
3331
|
+
*/
|
|
3332
|
+
get = (...args) => new GetCommand(args, this.opts).exec(this.client);
|
|
3333
|
+
/**
|
|
3334
|
+
* @see https://redis.io/commands/getbit
|
|
3335
|
+
*/
|
|
3336
|
+
getbit = (...args) => new GetBitCommand(args, this.opts).exec(this.client);
|
|
3337
|
+
/**
|
|
3338
|
+
* @see https://redis.io/commands/getdel
|
|
3339
|
+
*/
|
|
3340
|
+
getdel = (...args) => new GetDelCommand(args, this.opts).exec(this.client);
|
|
3341
|
+
/**
|
|
3342
|
+
* @see https://redis.io/commands/getrange
|
|
3343
|
+
*/
|
|
3344
|
+
getrange = (...args) => new GetRangeCommand(args, this.opts).exec(this.client);
|
|
3345
|
+
/**
|
|
3346
|
+
* @see https://redis.io/commands/getset
|
|
3347
|
+
*/
|
|
3348
|
+
getset = (key, value) => new GetSetCommand([key, value], this.opts).exec(this.client);
|
|
3349
|
+
/**
|
|
3350
|
+
* @see https://redis.io/commands/hdel
|
|
3351
|
+
*/
|
|
3352
|
+
hdel = (...args) => new HDelCommand(args, this.opts).exec(this.client);
|
|
3353
|
+
/**
|
|
3354
|
+
* @see https://redis.io/commands/hexists
|
|
3355
|
+
*/
|
|
3356
|
+
hexists = (...args) => new HExistsCommand(args, this.opts).exec(this.client);
|
|
3357
|
+
/**
|
|
3358
|
+
* @see https://redis.io/commands/hget
|
|
3359
|
+
*/
|
|
3360
|
+
hget = (...args) => new HGetCommand(args, this.opts).exec(this.client);
|
|
3361
|
+
/**
|
|
3362
|
+
* @see https://redis.io/commands/hgetall
|
|
3363
|
+
*/
|
|
3364
|
+
hgetall = (...args) => new HGetAllCommand(args, this.opts).exec(this.client);
|
|
3365
|
+
/**
|
|
3366
|
+
* @see https://redis.io/commands/hincrby
|
|
3367
|
+
*/
|
|
3368
|
+
hincrby = (...args) => new HIncrByCommand(args, this.opts).exec(this.client);
|
|
3369
|
+
/**
|
|
3370
|
+
* @see https://redis.io/commands/hincrbyfloat
|
|
3371
|
+
*/
|
|
3372
|
+
hincrbyfloat = (...args) => new HIncrByFloatCommand(args, this.opts).exec(this.client);
|
|
3373
|
+
/**
|
|
3374
|
+
* @see https://redis.io/commands/hkeys
|
|
3375
|
+
*/
|
|
3376
|
+
hkeys = (...args) => new HKeysCommand(args, this.opts).exec(this.client);
|
|
3377
|
+
/**
|
|
3378
|
+
* @see https://redis.io/commands/hlen
|
|
3379
|
+
*/
|
|
3380
|
+
hlen = (...args) => new HLenCommand(args, this.opts).exec(this.client);
|
|
3381
|
+
/**
|
|
3382
|
+
* @see https://redis.io/commands/hmget
|
|
3383
|
+
*/
|
|
3384
|
+
hmget = (...args) => new HMGetCommand(args, this.opts).exec(this.client);
|
|
3385
|
+
/**
|
|
3386
|
+
* @see https://redis.io/commands/hmset
|
|
3387
|
+
*/
|
|
3388
|
+
hmset = (key, kv) => new HMSetCommand([key, kv], this.opts).exec(this.client);
|
|
3389
|
+
/**
|
|
3390
|
+
* @see https://redis.io/commands/hrandfield
|
|
3391
|
+
*/
|
|
3392
|
+
hrandfield = (key, count, withValues) => new HRandFieldCommand([key, count, withValues], this.opts).exec(this.client);
|
|
3393
|
+
/**
|
|
3394
|
+
* @see https://redis.io/commands/hscan
|
|
3395
|
+
*/
|
|
3396
|
+
hscan = (...args) => new HScanCommand(args, this.opts).exec(this.client);
|
|
3397
|
+
/**
|
|
3398
|
+
* @see https://redis.io/commands/hset
|
|
3399
|
+
*/
|
|
3400
|
+
hset = (key, kv) => new HSetCommand([key, kv], this.opts).exec(this.client);
|
|
3401
|
+
/**
|
|
3402
|
+
* @see https://redis.io/commands/hsetnx
|
|
3403
|
+
*/
|
|
3404
|
+
hsetnx = (key, field, value) => new HSetNXCommand([key, field, value], this.opts).exec(this.client);
|
|
3405
|
+
/**
|
|
3406
|
+
* @see https://redis.io/commands/hstrlen
|
|
3407
|
+
*/
|
|
3408
|
+
hstrlen = (...args) => new HStrLenCommand(args, this.opts).exec(this.client);
|
|
3409
|
+
/**
|
|
3410
|
+
* @see https://redis.io/commands/hvals
|
|
3411
|
+
*/
|
|
3412
|
+
hvals = (...args) => new HValsCommand(args, this.opts).exec(this.client);
|
|
3413
|
+
/**
|
|
3414
|
+
* @see https://redis.io/commands/incr
|
|
3415
|
+
*/
|
|
3416
|
+
incr = (...args) => new IncrCommand(args, this.opts).exec(this.client);
|
|
3417
|
+
/**
|
|
3418
|
+
* @see https://redis.io/commands/incrby
|
|
3419
|
+
*/
|
|
3420
|
+
incrby = (...args) => new IncrByCommand(args, this.opts).exec(this.client);
|
|
3421
|
+
/**
|
|
3422
|
+
* @see https://redis.io/commands/incrbyfloat
|
|
3423
|
+
*/
|
|
3424
|
+
incrbyfloat = (...args) => new IncrByFloatCommand(args, this.opts).exec(this.client);
|
|
3425
|
+
/**
|
|
3426
|
+
* @see https://redis.io/commands/keys
|
|
3427
|
+
*/
|
|
3428
|
+
keys = (...args) => new KeysCommand(args, this.opts).exec(this.client);
|
|
3429
|
+
/**
|
|
3430
|
+
* @see https://redis.io/commands/lindex
|
|
3431
|
+
*/
|
|
3432
|
+
lindex = (...args) => new LIndexCommand(args, this.opts).exec(this.client);
|
|
3433
|
+
/**
|
|
3434
|
+
* @see https://redis.io/commands/linsert
|
|
3435
|
+
*/
|
|
3436
|
+
linsert = (key, direction, pivot, value) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client);
|
|
3437
|
+
/**
|
|
3438
|
+
* @see https://redis.io/commands/llen
|
|
3439
|
+
*/
|
|
3440
|
+
llen = (...args) => new LLenCommand(args, this.opts).exec(this.client);
|
|
3441
|
+
/**
|
|
3442
|
+
* @see https://redis.io/commands/lmove
|
|
3443
|
+
*/
|
|
3444
|
+
lmove = (...args) => new LMoveCommand(args, this.opts).exec(this.client);
|
|
3445
|
+
/**
|
|
3446
|
+
* @see https://redis.io/commands/lpop
|
|
3447
|
+
*/
|
|
3448
|
+
lpop = (...args) => new LPopCommand(args, this.opts).exec(this.client);
|
|
3449
|
+
/**
|
|
3450
|
+
* @see https://redis.io/commands/lmpop
|
|
3451
|
+
*/
|
|
3452
|
+
lmpop = (...args) => new LmPopCommand(args, this.opts).exec(this.client);
|
|
3453
|
+
/**
|
|
3454
|
+
* @see https://redis.io/commands/lpos
|
|
3455
|
+
*/
|
|
3456
|
+
lpos = (...args) => new LPosCommand(args, this.opts).exec(this.client);
|
|
3457
|
+
/**
|
|
3458
|
+
* @see https://redis.io/commands/lpush
|
|
3459
|
+
*/
|
|
3460
|
+
lpush = (key, ...elements) => new LPushCommand([key, ...elements], this.opts).exec(this.client);
|
|
3461
|
+
/**
|
|
3462
|
+
* @see https://redis.io/commands/lpushx
|
|
3463
|
+
*/
|
|
3464
|
+
lpushx = (key, ...elements) => new LPushXCommand([key, ...elements], this.opts).exec(this.client);
|
|
3465
|
+
/**
|
|
3466
|
+
* @see https://redis.io/commands/lrange
|
|
3467
|
+
*/
|
|
3468
|
+
lrange = (...args) => new LRangeCommand(args, this.opts).exec(this.client);
|
|
3469
|
+
/**
|
|
3470
|
+
* @see https://redis.io/commands/lrem
|
|
3471
|
+
*/
|
|
3472
|
+
lrem = (key, count, value) => new LRemCommand([key, count, value], this.opts).exec(this.client);
|
|
3473
|
+
/**
|
|
3474
|
+
* @see https://redis.io/commands/lset
|
|
3475
|
+
*/
|
|
3476
|
+
lset = (key, index, value) => new LSetCommand([key, index, value], this.opts).exec(this.client);
|
|
3477
|
+
/**
|
|
3478
|
+
* @see https://redis.io/commands/ltrim
|
|
3479
|
+
*/
|
|
3480
|
+
ltrim = (...args) => new LTrimCommand(args, this.opts).exec(this.client);
|
|
3481
|
+
/**
|
|
3482
|
+
* @see https://redis.io/commands/mget
|
|
3483
|
+
*/
|
|
3484
|
+
mget = (...args) => new MGetCommand(args, this.opts).exec(this.client);
|
|
3485
|
+
/**
|
|
3486
|
+
* @see https://redis.io/commands/mset
|
|
3487
|
+
*/
|
|
3488
|
+
mset = (kv) => new MSetCommand([kv], this.opts).exec(this.client);
|
|
3489
|
+
/**
|
|
3490
|
+
* @see https://redis.io/commands/msetnx
|
|
3491
|
+
*/
|
|
3492
|
+
msetnx = (kv) => new MSetNXCommand([kv], this.opts).exec(this.client);
|
|
3493
|
+
/**
|
|
3494
|
+
* @see https://redis.io/commands/persist
|
|
3495
|
+
*/
|
|
3496
|
+
persist = (...args) => new PersistCommand(args, this.opts).exec(this.client);
|
|
3497
|
+
/**
|
|
3498
|
+
* @see https://redis.io/commands/pexpire
|
|
3499
|
+
*/
|
|
3500
|
+
pexpire = (...args) => new PExpireCommand(args, this.opts).exec(this.client);
|
|
3501
|
+
/**
|
|
3502
|
+
* @see https://redis.io/commands/pexpireat
|
|
3503
|
+
*/
|
|
3504
|
+
pexpireat = (...args) => new PExpireAtCommand(args, this.opts).exec(this.client);
|
|
3505
|
+
/**
|
|
3506
|
+
* @see https://redis.io/commands/pfadd
|
|
3507
|
+
*/
|
|
3508
|
+
pfadd = (...args) => new PfAddCommand(args, this.opts).exec(this.client);
|
|
3509
|
+
/**
|
|
3510
|
+
* @see https://redis.io/commands/pfcount
|
|
3511
|
+
*/
|
|
3512
|
+
pfcount = (...args) => new PfCountCommand(args, this.opts).exec(this.client);
|
|
3513
|
+
/**
|
|
3514
|
+
* @see https://redis.io/commands/pfmerge
|
|
3515
|
+
*/
|
|
3516
|
+
pfmerge = (...args) => new PfMergeCommand(args, this.opts).exec(this.client);
|
|
3517
|
+
/**
|
|
3518
|
+
* @see https://redis.io/commands/ping
|
|
3519
|
+
*/
|
|
3520
|
+
ping = (args) => new PingCommand(args, this.opts).exec(this.client);
|
|
3521
|
+
/**
|
|
3522
|
+
* @see https://redis.io/commands/psetex
|
|
3523
|
+
*/
|
|
3524
|
+
psetex = (key, ttl, value) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client);
|
|
3525
|
+
/**
|
|
3526
|
+
* @see https://redis.io/commands/pttl
|
|
3527
|
+
*/
|
|
3528
|
+
pttl = (...args) => new PTtlCommand(args, this.opts).exec(this.client);
|
|
3529
|
+
/**
|
|
3530
|
+
* @see https://redis.io/commands/publish
|
|
3531
|
+
*/
|
|
3532
|
+
publish = (...args) => new PublishCommand(args, this.opts).exec(this.client);
|
|
3533
|
+
/**
|
|
3534
|
+
* @see https://redis.io/commands/randomkey
|
|
3535
|
+
*/
|
|
3536
|
+
randomkey = () => new RandomKeyCommand().exec(this.client);
|
|
3537
|
+
/**
|
|
3538
|
+
* @see https://redis.io/commands/rename
|
|
3539
|
+
*/
|
|
3540
|
+
rename = (...args) => new RenameCommand(args, this.opts).exec(this.client);
|
|
3541
|
+
/**
|
|
3542
|
+
* @see https://redis.io/commands/renamenx
|
|
3543
|
+
*/
|
|
3544
|
+
renamenx = (...args) => new RenameNXCommand(args, this.opts).exec(this.client);
|
|
3545
|
+
/**
|
|
3546
|
+
* @see https://redis.io/commands/rpop
|
|
3547
|
+
*/
|
|
3548
|
+
rpop = (...args) => new RPopCommand(args, this.opts).exec(this.client);
|
|
3549
|
+
/**
|
|
3550
|
+
* @see https://redis.io/commands/rpush
|
|
3551
|
+
*/
|
|
3552
|
+
rpush = (key, ...elements) => new RPushCommand([key, ...elements], this.opts).exec(this.client);
|
|
3553
|
+
/**
|
|
3554
|
+
* @see https://redis.io/commands/rpushx
|
|
3555
|
+
*/
|
|
3556
|
+
rpushx = (key, ...elements) => new RPushXCommand([key, ...elements], this.opts).exec(this.client);
|
|
3557
|
+
/**
|
|
3558
|
+
* @see https://redis.io/commands/sadd
|
|
3559
|
+
*/
|
|
3560
|
+
sadd = (key, member, ...members) => new SAddCommand([key, member, ...members], this.opts).exec(this.client);
|
|
3561
|
+
/**
|
|
3562
|
+
* @see https://redis.io/commands/scan
|
|
3563
|
+
*/
|
|
3564
|
+
scan = (...args) => new ScanCommand(args, this.opts).exec(this.client);
|
|
3565
|
+
/**
|
|
3566
|
+
* @see https://redis.io/commands/scard
|
|
3567
|
+
*/
|
|
3568
|
+
scard = (...args) => new SCardCommand(args, this.opts).exec(this.client);
|
|
3569
|
+
/**
|
|
3570
|
+
* @see https://redis.io/commands/script-exists
|
|
3571
|
+
*/
|
|
3572
|
+
scriptExists = (...args) => new ScriptExistsCommand(args, this.opts).exec(this.client);
|
|
3573
|
+
/**
|
|
3574
|
+
* @see https://redis.io/commands/script-flush
|
|
3575
|
+
*/
|
|
3576
|
+
scriptFlush = (...args) => new ScriptFlushCommand(args, this.opts).exec(this.client);
|
|
3577
|
+
/**
|
|
3578
|
+
* @see https://redis.io/commands/script-load
|
|
3579
|
+
*/
|
|
3580
|
+
scriptLoad = (...args) => new ScriptLoadCommand(args, this.opts).exec(this.client);
|
|
3581
|
+
/**
|
|
3582
|
+
* @see https://redis.io/commands/sdiff
|
|
3583
|
+
*/
|
|
3584
|
+
sdiff = (...args) => new SDiffCommand(args, this.opts).exec(this.client);
|
|
3585
|
+
/**
|
|
3586
|
+
* @see https://redis.io/commands/sdiffstore
|
|
3587
|
+
*/
|
|
3588
|
+
sdiffstore = (...args) => new SDiffStoreCommand(args, this.opts).exec(this.client);
|
|
3589
|
+
/**
|
|
3590
|
+
* @see https://redis.io/commands/set
|
|
3591
|
+
*/
|
|
3592
|
+
set = (key, value, opts) => new SetCommand([key, value, opts], this.opts).exec(this.client);
|
|
3593
|
+
/**
|
|
3594
|
+
* @see https://redis.io/commands/setbit
|
|
3595
|
+
*/
|
|
3596
|
+
setbit = (...args) => new SetBitCommand(args, this.opts).exec(this.client);
|
|
3597
|
+
/**
|
|
3598
|
+
* @see https://redis.io/commands/setex
|
|
3599
|
+
*/
|
|
3600
|
+
setex = (key, ttl, value) => new SetExCommand([key, ttl, value], this.opts).exec(this.client);
|
|
3601
|
+
/**
|
|
3602
|
+
* @see https://redis.io/commands/setnx
|
|
3603
|
+
*/
|
|
3604
|
+
setnx = (key, value) => new SetNxCommand([key, value], this.opts).exec(this.client);
|
|
3605
|
+
/**
|
|
3606
|
+
* @see https://redis.io/commands/setrange
|
|
3607
|
+
*/
|
|
3608
|
+
setrange = (...args) => new SetRangeCommand(args, this.opts).exec(this.client);
|
|
3609
|
+
/**
|
|
3610
|
+
* @see https://redis.io/commands/sinter
|
|
3611
|
+
*/
|
|
3612
|
+
sinter = (...args) => new SInterCommand(args, this.opts).exec(this.client);
|
|
3613
|
+
/**
|
|
3614
|
+
* @see https://redis.io/commands/sinterstore
|
|
3615
|
+
*/
|
|
3616
|
+
sinterstore = (...args) => new SInterStoreCommand(args, this.opts).exec(this.client);
|
|
3617
|
+
/**
|
|
3618
|
+
* @see https://redis.io/commands/sismember
|
|
3619
|
+
*/
|
|
3620
|
+
sismember = (key, member) => new SIsMemberCommand([key, member], this.opts).exec(this.client);
|
|
3621
|
+
/**
|
|
3622
|
+
* @see https://redis.io/commands/smismember
|
|
3623
|
+
*/
|
|
3624
|
+
smismember = (key, members) => new SMIsMemberCommand([key, members], this.opts).exec(this.client);
|
|
3625
|
+
/**
|
|
3626
|
+
* @see https://redis.io/commands/smembers
|
|
3627
|
+
*/
|
|
3628
|
+
smembers = (...args) => new SMembersCommand(args, this.opts).exec(this.client);
|
|
3629
|
+
/**
|
|
3630
|
+
* @see https://redis.io/commands/smove
|
|
3631
|
+
*/
|
|
3632
|
+
smove = (source, destination, member) => new SMoveCommand([source, destination, member], this.opts).exec(this.client);
|
|
3633
|
+
/**
|
|
3634
|
+
* @see https://redis.io/commands/spop
|
|
3635
|
+
*/
|
|
3636
|
+
spop = (...args) => new SPopCommand(args, this.opts).exec(this.client);
|
|
3637
|
+
/**
|
|
3638
|
+
* @see https://redis.io/commands/srandmember
|
|
3639
|
+
*/
|
|
3640
|
+
srandmember = (...args) => new SRandMemberCommand(args, this.opts).exec(this.client);
|
|
3641
|
+
/**
|
|
3642
|
+
* @see https://redis.io/commands/srem
|
|
3643
|
+
*/
|
|
3644
|
+
srem = (key, ...members) => new SRemCommand([key, ...members], this.opts).exec(this.client);
|
|
3645
|
+
/**
|
|
3646
|
+
* @see https://redis.io/commands/sscan
|
|
3647
|
+
*/
|
|
3648
|
+
sscan = (...args) => new SScanCommand(args, this.opts).exec(this.client);
|
|
3649
|
+
/**
|
|
3650
|
+
* @see https://redis.io/commands/strlen
|
|
3651
|
+
*/
|
|
3652
|
+
strlen = (...args) => new StrLenCommand(args, this.opts).exec(this.client);
|
|
3653
|
+
/**
|
|
3654
|
+
* @see https://redis.io/commands/sunion
|
|
3655
|
+
*/
|
|
3656
|
+
sunion = (...args) => new SUnionCommand(args, this.opts).exec(this.client);
|
|
3657
|
+
/**
|
|
3658
|
+
* @see https://redis.io/commands/sunionstore
|
|
3659
|
+
*/
|
|
3660
|
+
sunionstore = (...args) => new SUnionStoreCommand(args, this.opts).exec(this.client);
|
|
3661
|
+
/**
|
|
3662
|
+
* @see https://redis.io/commands/time
|
|
3663
|
+
*/
|
|
3664
|
+
time = () => new TimeCommand().exec(this.client);
|
|
3665
|
+
/**
|
|
3666
|
+
* @see https://redis.io/commands/touch
|
|
3667
|
+
*/
|
|
3668
|
+
touch = (...args) => new TouchCommand(args, this.opts).exec(this.client);
|
|
3669
|
+
/**
|
|
3670
|
+
* @see https://redis.io/commands/ttl
|
|
3671
|
+
*/
|
|
3672
|
+
ttl = (...args) => new TtlCommand(args, this.opts).exec(this.client);
|
|
3673
|
+
/**
|
|
3674
|
+
* @see https://redis.io/commands/type
|
|
3675
|
+
*/
|
|
3676
|
+
type = (...args) => new TypeCommand(args, this.opts).exec(this.client);
|
|
3677
|
+
/**
|
|
3678
|
+
* @see https://redis.io/commands/unlink
|
|
3679
|
+
*/
|
|
3680
|
+
unlink = (...args) => new UnlinkCommand(args, this.opts).exec(this.client);
|
|
3681
|
+
/**
|
|
3682
|
+
* @see https://redis.io/commands/xadd
|
|
3683
|
+
*/
|
|
3684
|
+
xadd = (...args) => new XAddCommand(args, this.opts).exec(this.client);
|
|
3685
|
+
/**
|
|
3686
|
+
* @see https://redis.io/commands/xack
|
|
3687
|
+
*/
|
|
3688
|
+
xack = (...args) => new XAckCommand(args, this.opts).exec(this.client);
|
|
3689
|
+
/**
|
|
3690
|
+
* @see https://redis.io/commands/xdel
|
|
3691
|
+
*/
|
|
3692
|
+
xdel = (...args) => new XDelCommand(args, this.opts).exec(this.client);
|
|
3693
|
+
/**
|
|
3694
|
+
* @see https://redis.io/commands/xgroup
|
|
3695
|
+
*/
|
|
3696
|
+
xgroup = (...args) => new XGroupCommand(args, this.opts).exec(this.client);
|
|
3697
|
+
/**
|
|
3698
|
+
* @see https://redis.io/commands/xread
|
|
3699
|
+
*/
|
|
3700
|
+
xread = (...args) => new XReadCommand(args, this.opts).exec(this.client);
|
|
3701
|
+
/**
|
|
3702
|
+
* @see https://redis.io/commands/xreadgroup
|
|
3703
|
+
*/
|
|
3704
|
+
xreadgroup = (...args) => new XReadGroupCommand(args, this.opts).exec(this.client);
|
|
3705
|
+
/**
|
|
3706
|
+
* @see https://redis.io/commands/xinfo
|
|
3707
|
+
*/
|
|
3708
|
+
xinfo = (...args) => new XInfoCommand(args, this.opts).exec(this.client);
|
|
3709
|
+
/**
|
|
3710
|
+
* @see https://redis.io/commands/xlen
|
|
3711
|
+
*/
|
|
3712
|
+
xlen = (...args) => new XLenCommand(args, this.opts).exec(this.client);
|
|
3713
|
+
/**
|
|
3714
|
+
* @see https://redis.io/commands/xpending
|
|
3715
|
+
*/
|
|
3716
|
+
xpending = (...args) => new XPendingCommand(args, this.opts).exec(this.client);
|
|
3717
|
+
/**
|
|
3718
|
+
* @see https://redis.io/commands/xclaim
|
|
3719
|
+
*/
|
|
3720
|
+
xclaim = (...args) => new XClaimCommand(args, this.opts).exec(this.client);
|
|
3721
|
+
/**
|
|
3722
|
+
* @see https://redis.io/commands/xautoclaim
|
|
3723
|
+
*/
|
|
3724
|
+
xautoclaim = (...args) => new XAutoClaim(args, this.opts).exec(this.client);
|
|
3725
|
+
/**
|
|
3726
|
+
* @see https://redis.io/commands/xtrim
|
|
3727
|
+
*/
|
|
3728
|
+
xtrim = (...args) => new XTrimCommand(args, this.opts).exec(this.client);
|
|
3729
|
+
/**
|
|
3730
|
+
* @see https://redis.io/commands/xrange
|
|
3731
|
+
*/
|
|
3732
|
+
xrange = (...args) => new XRangeCommand(args, this.opts).exec(this.client);
|
|
3733
|
+
/**
|
|
3734
|
+
* @see https://redis.io/commands/xrevrange
|
|
3735
|
+
*/
|
|
3736
|
+
xrevrange = (...args) => new XRevRangeCommand(args, this.opts).exec(this.client);
|
|
3737
|
+
/**
|
|
3738
|
+
* @see https://redis.io/commands/zadd
|
|
3739
|
+
*/
|
|
3740
|
+
zadd = (...args) => {
|
|
3741
|
+
if ("score" in args[1]) {
|
|
3742
|
+
return new ZAddCommand([args[0], args[1], ...args.slice(2)], this.opts).exec(
|
|
3743
|
+
this.client
|
|
3744
|
+
);
|
|
3745
|
+
}
|
|
3746
|
+
return new ZAddCommand(
|
|
3747
|
+
[args[0], args[1], ...args.slice(2)],
|
|
3748
|
+
this.opts
|
|
3749
|
+
).exec(this.client);
|
|
3750
|
+
};
|
|
3751
|
+
/**
|
|
3752
|
+
* @see https://redis.io/commands/zcard
|
|
3753
|
+
*/
|
|
3754
|
+
zcard = (...args) => new ZCardCommand(args, this.opts).exec(this.client);
|
|
3755
|
+
/**
|
|
3756
|
+
* @see https://redis.io/commands/zcount
|
|
3757
|
+
*/
|
|
3758
|
+
zcount = (...args) => new ZCountCommand(args, this.opts).exec(this.client);
|
|
3759
|
+
/**
|
|
3760
|
+
* @see https://redis.io/commands/zdiffstore
|
|
3761
|
+
*/
|
|
3762
|
+
zdiffstore = (...args) => new ZDiffStoreCommand(args, this.opts).exec(this.client);
|
|
3763
|
+
/**
|
|
3764
|
+
* @see https://redis.io/commands/zincrby
|
|
3765
|
+
*/
|
|
3766
|
+
zincrby = (key, increment, member) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client);
|
|
3767
|
+
/**
|
|
3768
|
+
* @see https://redis.io/commands/zinterstore
|
|
3769
|
+
*/
|
|
3770
|
+
zinterstore = (...args) => new ZInterStoreCommand(args, this.opts).exec(this.client);
|
|
3771
|
+
/**
|
|
3772
|
+
* @see https://redis.io/commands/zlexcount
|
|
3773
|
+
*/
|
|
3774
|
+
zlexcount = (...args) => new ZLexCountCommand(args, this.opts).exec(this.client);
|
|
3775
|
+
/**
|
|
3776
|
+
* @see https://redis.io/commands/zmscore
|
|
3777
|
+
*/
|
|
3778
|
+
zmscore = (...args) => new ZMScoreCommand(args, this.opts).exec(this.client);
|
|
3779
|
+
/**
|
|
3780
|
+
* @see https://redis.io/commands/zpopmax
|
|
3781
|
+
*/
|
|
3782
|
+
zpopmax = (...args) => new ZPopMaxCommand(args, this.opts).exec(this.client);
|
|
3783
|
+
/**
|
|
3784
|
+
* @see https://redis.io/commands/zpopmin
|
|
3785
|
+
*/
|
|
3786
|
+
zpopmin = (...args) => new ZPopMinCommand(args, this.opts).exec(this.client);
|
|
3787
|
+
/**
|
|
3788
|
+
* @see https://redis.io/commands/zrange
|
|
3789
|
+
*/
|
|
3790
|
+
zrange = (...args) => new ZRangeCommand(args, this.opts).exec(this.client);
|
|
3791
|
+
/**
|
|
3792
|
+
* @see https://redis.io/commands/zrank
|
|
3793
|
+
*/
|
|
3794
|
+
zrank = (key, member) => new ZRankCommand([key, member], this.opts).exec(this.client);
|
|
3795
|
+
/**
|
|
3796
|
+
* @see https://redis.io/commands/zrem
|
|
3797
|
+
*/
|
|
3798
|
+
zrem = (key, ...members) => new ZRemCommand([key, ...members], this.opts).exec(this.client);
|
|
3799
|
+
/**
|
|
3800
|
+
* @see https://redis.io/commands/zremrangebylex
|
|
3801
|
+
*/
|
|
3802
|
+
zremrangebylex = (...args) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client);
|
|
3803
|
+
/**
|
|
3804
|
+
* @see https://redis.io/commands/zremrangebyrank
|
|
3805
|
+
*/
|
|
3806
|
+
zremrangebyrank = (...args) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client);
|
|
3807
|
+
/**
|
|
3808
|
+
* @see https://redis.io/commands/zremrangebyscore
|
|
3809
|
+
*/
|
|
3810
|
+
zremrangebyscore = (...args) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client);
|
|
3811
|
+
/**
|
|
3812
|
+
* @see https://redis.io/commands/zrevrank
|
|
3813
|
+
*/
|
|
3814
|
+
zrevrank = (key, member) => new ZRevRankCommand([key, member], this.opts).exec(this.client);
|
|
3815
|
+
/**
|
|
3816
|
+
* @see https://redis.io/commands/zscan
|
|
3817
|
+
*/
|
|
3818
|
+
zscan = (...args) => new ZScanCommand(args, this.opts).exec(this.client);
|
|
3819
|
+
/**
|
|
3820
|
+
* @see https://redis.io/commands/zscore
|
|
3821
|
+
*/
|
|
3822
|
+
zscore = (key, member) => new ZScoreCommand([key, member], this.opts).exec(this.client);
|
|
3823
|
+
/**
|
|
3824
|
+
* @see https://redis.io/commands/zunion
|
|
3825
|
+
*/
|
|
3826
|
+
zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
|
|
3827
|
+
/**
|
|
3828
|
+
* @see https://redis.io/commands/zunionstore
|
|
3829
|
+
*/
|
|
3830
|
+
zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
|
|
3831
|
+
};
|
|
3832
|
+
|
|
3833
|
+
// version.ts
|
|
3834
|
+
var VERSION = "1.34.3-canary";
|
|
3835
|
+
|
|
3836
|
+
// platforms/nodejs.ts
|
|
3837
|
+
if (typeof atob === "undefined") {
|
|
3838
|
+
global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
|
|
3839
|
+
}
|
|
3840
|
+
var Redis2 = class _Redis extends Redis {
|
|
3841
|
+
/**
|
|
3842
|
+
* Create a new redis client by providing a custom `Requester` implementation
|
|
3843
|
+
*
|
|
3844
|
+
* @example
|
|
3845
|
+
* ```ts
|
|
3846
|
+
*
|
|
3847
|
+
* import { UpstashRequest, Requester, UpstashResponse, Redis } from "@upstash/redis"
|
|
3848
|
+
*
|
|
3849
|
+
* const requester: Requester = {
|
|
3850
|
+
* request: <TResult>(req: UpstashRequest): Promise<UpstashResponse<TResult>> => {
|
|
3851
|
+
* // ...
|
|
3852
|
+
* }
|
|
3853
|
+
* }
|
|
3854
|
+
*
|
|
3855
|
+
* const redis = new Redis(requester)
|
|
3856
|
+
* ```
|
|
3857
|
+
*/
|
|
3858
|
+
constructor(configOrRequester) {
|
|
3859
|
+
if ("request" in configOrRequester) {
|
|
3860
|
+
super(configOrRequester);
|
|
3861
|
+
return;
|
|
3862
|
+
}
|
|
3863
|
+
if (!configOrRequester.url) {
|
|
3864
|
+
console.warn(
|
|
3865
|
+
`[Upstash Redis] The 'url' property is missing or undefined in your Redis config.`
|
|
3866
|
+
);
|
|
3867
|
+
}
|
|
3868
|
+
if (!configOrRequester.token) {
|
|
3869
|
+
console.warn(
|
|
3870
|
+
`[Upstash Redis] The 'token' property is missing or undefined in your Redis config.`
|
|
3871
|
+
);
|
|
3872
|
+
}
|
|
3873
|
+
if (configOrRequester.url.startsWith(" ") || configOrRequester.url.endsWith(" ") || /\r|\n/.test(configOrRequester.url)) {
|
|
3874
|
+
console.warn(
|
|
3875
|
+
"[Upstash Redis] The redis url contains whitespace or newline, which can cause errors!"
|
|
3876
|
+
);
|
|
3877
|
+
}
|
|
3878
|
+
if (configOrRequester.token.startsWith(" ") || configOrRequester.token.endsWith(" ") || /\r|\n/.test(configOrRequester.token)) {
|
|
3879
|
+
console.warn(
|
|
3880
|
+
"[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
|
|
3881
|
+
);
|
|
3882
|
+
}
|
|
3883
|
+
const client = new HttpClient({
|
|
3884
|
+
baseUrl: configOrRequester.url,
|
|
3885
|
+
retry: configOrRequester.retry,
|
|
3886
|
+
headers: { authorization: `Bearer ${configOrRequester.token}` },
|
|
3887
|
+
agent: configOrRequester.agent,
|
|
3888
|
+
responseEncoding: configOrRequester.responseEncoding,
|
|
3889
|
+
cache: configOrRequester.cache ?? "no-store",
|
|
3890
|
+
signal: configOrRequester.signal,
|
|
3891
|
+
keepAlive: configOrRequester.keepAlive,
|
|
3892
|
+
readYourWrites: configOrRequester.readYourWrites
|
|
3893
|
+
});
|
|
3894
|
+
super(client, {
|
|
3895
|
+
automaticDeserialization: configOrRequester.automaticDeserialization,
|
|
3896
|
+
enableTelemetry: !process.env.UPSTASH_DISABLE_TELEMETRY,
|
|
3897
|
+
latencyLogging: configOrRequester.latencyLogging,
|
|
3898
|
+
enableAutoPipelining: configOrRequester.enableAutoPipelining
|
|
3899
|
+
});
|
|
3900
|
+
this.addTelemetry({
|
|
3901
|
+
runtime: (
|
|
3902
|
+
// @ts-expect-error to silence compiler
|
|
3903
|
+
typeof EdgeRuntime === "string" ? "edge-light" : `node@${process.version}`
|
|
3904
|
+
),
|
|
3905
|
+
platform: process.env.VERCEL ? "vercel" : process.env.AWS_REGION ? "aws" : "unknown",
|
|
3906
|
+
sdk: `@upstash/redis@${VERSION}`
|
|
3907
|
+
});
|
|
3908
|
+
if (this.enableAutoPipelining) {
|
|
3909
|
+
return this.autoPipeline();
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
/**
|
|
3913
|
+
* Create a new Upstash Redis instance from environment variables.
|
|
3914
|
+
*
|
|
3915
|
+
* Use this to automatically load connection secrets from your environment
|
|
3916
|
+
* variables. For instance when using the Vercel integration.
|
|
3917
|
+
*
|
|
3918
|
+
* This tries to load `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` from
|
|
3919
|
+
* your environment using `process.env`.
|
|
3920
|
+
*/
|
|
3921
|
+
static fromEnv(config) {
|
|
3922
|
+
if (process.env === void 0) {
|
|
3923
|
+
throw new TypeError(
|
|
3924
|
+
'[Upstash Redis] Unable to get environment variables, `process.env` is undefined. If you are deploying to cloudflare, please import from "@upstash/redis/cloudflare" instead'
|
|
3925
|
+
);
|
|
3926
|
+
}
|
|
3927
|
+
const url = process.env.UPSTASH_REDIS_REST_URL;
|
|
3928
|
+
if (!url) {
|
|
3929
|
+
console.warn("[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_URL`");
|
|
3930
|
+
}
|
|
3931
|
+
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
3932
|
+
if (!token) {
|
|
3933
|
+
console.warn(
|
|
3934
|
+
"[Upstash Redis] Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`"
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3937
|
+
return new _Redis({ ...config, url, token });
|
|
3938
|
+
}
|
|
3939
|
+
};
|
|
3940
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3941
|
+
0 && (module.exports = {
|
|
3942
|
+
Redis,
|
|
3943
|
+
errors
|
|
3944
|
+
});
|