import type { Command, CommandOptions } from "./commands/command"; import { HRandFieldCommand } from "./commands/hrandfield"; import type { ScoreMember, SetCommandOptions, ZAddCommandOptions, ZRangeCommandOptions, } from "./commands/mod"; import type { ArGrepOptions, ArMSetValues, ArOpOperation } from "./commands/mod"; import { AppendCommand, ArCountCommand, ArDelCommand, ArDelRangeCommand, ArGetCommand, ArGetRangeCommand, ArGrepCommand, ArInfoCommand, ArInsertCommand, ArLastItemsCommand, ArLenCommand, ArMGetCommand, ArMSetCommand, ArNextCommand, ArOpCommand, ArRingCommand, ArScanCommand, ArSeekCommand, ArSetCommand, BitCountCommand, BitFieldCommand, BitOpCommand, BitPosCommand, ClientSetInfoCommand, CopyCommand, DBSizeCommand, DecrByCommand, DecrCommand, DelCommand, EchoCommand, EvalROCommand, EvalCommand, EvalshaROCommand, EvalshaCommand, ExistsCommand, ExpireAtCommand, ExpireCommand, FCallCommand, FCallRoCommand, FlushAllCommand, FlushDBCommand, FunctionDeleteCommand, FunctionFlushCommand, FunctionListCommand, FunctionLoadCommand, FunctionStatsCommand, GeoAddCommand, GeoDistCommand, GeoHashCommand, GeoPosCommand, GeoSearchCommand, GeoSearchStoreCommand, GetBitCommand, GetCommand, GetDelCommand, GetExCommand, GetRangeCommand, GetSetCommand, HDelCommand, HExistsCommand, HExpireCommand, HExpireAtCommand, HExpireTimeCommand, HTtlCommand, HPExpireCommand, HPExpireAtCommand, HPExpireTimeCommand, HPTtlCommand, HPersistCommand, HGetAllCommand, HGetCommand, HGetDelCommand, HGetExCommand, HIncrByCommand, HIncrByFloatCommand, HKeysCommand, HLenCommand, HMGetCommand, HMSetCommand, HScanCommand, HSetCommand, HSetExCommand, HSetNXCommand, HStrLenCommand, HValsCommand, IncrByCommand, IncrByFloatCommand, IncrCommand, JsonArrAppendCommand, JsonArrIndexCommand, JsonArrInsertCommand, JsonArrLenCommand, JsonArrPopCommand, JsonArrTrimCommand, JsonClearCommand, JsonDelCommand, JsonForgetCommand, JsonGetCommand, JsonMergeCommand, JsonMGetCommand, JsonMSetCommand, JsonNumIncrByCommand, JsonNumMultByCommand, JsonObjKeysCommand, JsonObjLenCommand, JsonRespCommand, JsonSetCommand, JsonStrAppendCommand, JsonStrLenCommand, JsonToggleCommand, JsonTypeCommand, KeysCommand, LIndexCommand, LInsertCommand, LLenCommand, LMoveCommand, LPopCommand, LPosCommand, LPushCommand, LPushXCommand, LRangeCommand, LRemCommand, LSetCommand, LTrimCommand, LmPopCommand, MGetCommand, MSetCommand, MSetNXCommand, PExpireAtCommand, PExpireCommand, PSetEXCommand, PTtlCommand, PersistCommand, PfAddCommand, PfCountCommand, PfMergeCommand, PingCommand, PublishCommand, RPopCommand, RPushCommand, RPushXCommand, RandomKeyCommand, RenameCommand, RenameNXCommand, SAddCommand, SCardCommand, SDiffCommand, SDiffStoreCommand, SInterCommand, SInterCardCommand, SInterStoreCommand, SIsMemberCommand, SMIsMemberCommand, SMembersCommand, SMoveCommand, SPopCommand, SRandMemberCommand, SRemCommand, SScanCommand, SUnionCommand, SUnionStoreCommand, ScanCommand, ScriptExistsCommand, ScriptFlushCommand, ScriptLoadCommand, SetBitCommand, SetCommand, SetExCommand, SetNxCommand, SetRangeCommand, StrLenCommand, TimeCommand, TouchCommand, TtlCommand, TypeCommand, UnlinkCommand, XAckCommand, XAckDelCommand, XAddCommand, XAutoClaim, XClaimCommand, XDelCommand, XDelExCommand, XGroupCommand, XInfoCommand, XLenCommand, XPendingCommand, XRangeCommand, XReadCommand, XReadGroupCommand, XRevRangeCommand, XTrimCommand, ZAddCommand, ZCardCommand, ZCountCommand, ZIncrByCommand, ZInterStoreCommand, ZLexCountCommand, ZPopMaxCommand, ZPopMinCommand, ZRangeCommand, ZRankCommand, ZRemCommand, ZRemRangeByLexCommand, ZRemRangeByRankCommand, ZRemRangeByScoreCommand, ZRevRankCommand, ZScanCommand, ZScoreCommand, ZUnionCommand, ZUnionStoreCommand, } from "./commands/mod"; import { ZDiffStoreCommand } from "./commands/zdiffstore"; import { ZMScoreCommand } from "./commands/zmscore"; import { UpstashError } from "./error"; import type { Requester, UpstashResponse } from "./http"; import type { CommandArgs } from "./types"; // Given a tuple of commands, returns a tuple of the response data of each command type InferResponseData = { [K in keyof T]: T[K] extends Command ? TData : unknown; }; interface ExecMethod[]> { /** * Send the pipeline request to upstash. * * Returns an array with the results of all pipelined commands. * * If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though: * ```ts * const p = redis.pipeline() * p.get("key") * const result = p.exec<[{ greeting: string }]>() * ``` * * If one of the commands get an error, the whole pipeline fails. Alternatively, you can set the keepErrors option to true in order to get the errors individually. * * If keepErrors is set to true, a list of objects is returned where each object corresponds to a command and is of type: `{ result: unknown, error?: string }`. * * ```ts * const p = redis.pipeline() * p.get("key") * * const result = await p.exec({ keepErrors: true }); * const getResult = result[0].result * const getError = result[0].error * ``` */ < TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData, >(): Promise; < TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData, >(options: { keepErrors: true; }): Promise<{ [K in keyof TCommandResults]: UpstashResponse }>; } /** * Upstash REST API supports command pipelining to send multiple commands in * batch, instead of sending each command one by one and waiting for a response. * When using pipelines, several commands are sent using a single HTTP request, * and a single JSON array response is returned. Each item in the response array * corresponds to the command in the same order within the pipeline. * * **NOTE:** * * Execution of the pipeline is not atomic. Even though each command in * the pipeline will be executed in order, commands sent by other clients can * interleave with the pipeline. * * **Examples:** * * ```ts * const p = redis.pipeline() // or redis.multi() * p.set("key","value") * p.get("key") * const res = await p.exec() * ``` * * You can also chain commands together * ```ts * const p = redis.pipeline() * const res = await p.set("key","value").get("key").exec() * ``` * * Return types are inferred if all commands are chained, but you can still * override the response type manually: * ```ts * redis.pipeline() * .set("key", { greeting: "hello"}) * .get("key") * .exec<["OK", { greeting: string } ]>() * * ``` */ export class Pipeline[] = []> { private client: Requester; private commands: TCommands; private commandOptions?: CommandOptions; private multiExec: boolean; constructor(opts: { client: Requester; commandOptions?: CommandOptions; multiExec?: boolean; }) { this.client = opts.client; this.commands = [] as unknown as TCommands; // the TCommands generic in the class definition is only used for carrying through chained command types and should never be explicitly set when instantiating the class this.commandOptions = opts.commandOptions; this.multiExec = opts.multiExec ?? false; if (this.commandOptions?.latencyLogging) { const originalExec = this.exec.bind(this); this.exec = async < TCommandResults extends unknown[] = [] extends TCommands ? unknown[] : InferResponseData, >(options?: { keepErrors: true; }): Promise => { const start = performance.now(); const result = await (options ? originalExec(options) : originalExec()); const end = performance.now(); const loggerResult = (end - start).toFixed(2); // eslint-disable-next-line no-console console.log( `Latency for \u001B[38;2;19;185;39m${ this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase() }\u001B[0m: \u001B[38;2;0;255;255m${loggerResult} ms\u001B[0m` ); return result as TCommandResults; }; } } exec: ExecMethod = async (options?: { keepErrors: true }) => { if (this.commands.length === 0) { throw new Error("Pipeline is empty"); } const path = this.multiExec ? ["multi-exec"] : ["pipeline"]; const res = (await this.client.request({ path, body: Object.values(this.commands).map((c) => c.command), })) as UpstashResponse[]; return options?.keepErrors ? res.map(({ error, result }, i) => { return { error: error, result: this.commands[i].deserialize(result), }; }) : res.map(({ error, result }, i) => { if (error) { throw new UpstashError( `Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}` ); } return this.commands[i].deserialize(result); }); }; /** * Returns the length of pipeline before the execution */ length(): number { return this.commands.length; } /** * Pushes a command into the pipeline and returns a chainable instance of the * pipeline */ private chain(command: Command): Pipeline<[...TCommands, Command]> { this.commands.push(command); return this as any; // TS thinks we're returning Pipeline<[]> here, because we're not creating a new instance of the class, hence the cast } /** * @see https://redis.io/commands/append * @see node_modules/@upstash/redis/docs/commands/string/append.mdx */ append = (...args: CommandArgs) => this.chain(new AppendCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arcount * @see node_modules/@upstash/redis/docs/commands/array/arcount.mdx */ arcount = (...args: CommandArgs) => this.chain(new ArCountCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/ardel * @see node_modules/@upstash/redis/docs/commands/array/ardel.mdx */ ardel = (...args: CommandArgs) => this.chain(new ArDelCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/ardelrange * @see node_modules/@upstash/redis/docs/commands/array/ardelrange.mdx */ ardelrange = (...args: CommandArgs) => this.chain(new ArDelRangeCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arget * @see node_modules/@upstash/redis/docs/commands/array/arget.mdx */ arget = (...args: CommandArgs) => this.chain(new ArGetCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/argetrange * @see node_modules/@upstash/redis/docs/commands/array/argetrange.mdx */ argetrange = (...args: CommandArgs) => this.chain(new ArGetRangeCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/argrep * @see node_modules/@upstash/redis/docs/commands/array/argrep.mdx */ argrep = ( key: string, start: number | string, end: number | string, opts: TOpts ) => this.chain(new ArGrepCommand([key, start, end, opts], this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arinfo * @see node_modules/@upstash/redis/docs/commands/array/arinfo.mdx */ arinfo = (...args: CommandArgs) => this.chain(new ArInfoCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arinsert * @see node_modules/@upstash/redis/docs/commands/array/arinsert.mdx */ arinsert = (key: string, ...values: TData[]) => this.chain(new ArInsertCommand([key, ...values], this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arlastitems * @see node_modules/@upstash/redis/docs/commands/array/arlastitems.mdx */ arlastitems = (...args: CommandArgs) => this.chain(new ArLastItemsCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arlen * @see node_modules/@upstash/redis/docs/commands/array/arlen.mdx */ arlen = (...args: CommandArgs) => this.chain(new ArLenCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/armget * @see node_modules/@upstash/redis/docs/commands/array/armget.mdx */ armget = (...args: CommandArgs) => this.chain(new ArMGetCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/armset * @see node_modules/@upstash/redis/docs/commands/array/armset.mdx */ armset = (key: string, values: ArMSetValues) => this.chain(new ArMSetCommand([key, values], this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arnext * @see node_modules/@upstash/redis/docs/commands/array/arnext.mdx */ arnext = (...args: CommandArgs) => this.chain(new ArNextCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arop * @see node_modules/@upstash/redis/docs/commands/array/arop.mdx */ arop = ( key: string, start: number | string, end: number | string, operation: ArOpOperation ) => this.chain(new ArOpCommand([key, start, end, operation], this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arring * @see node_modules/@upstash/redis/docs/commands/array/arring.mdx */ arring = (key: string, size: number, ...values: TData[]) => this.chain(new ArRingCommand([key, size, ...values], this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arscan * @see node_modules/@upstash/redis/docs/commands/array/arscan.mdx */ arscan = (...args: CommandArgs) => this.chain(new ArScanCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arseek * @see node_modules/@upstash/redis/docs/commands/array/arseek.mdx */ arseek = (...args: CommandArgs) => this.chain(new ArSeekCommand(args, this.commandOptions)); /** * @see https://upstash.com/docs/redis/commands/array/arset * @see node_modules/@upstash/redis/docs/commands/array/arset.mdx */ arset = (key: string, index: number | string, ...values: TData[]) => this.chain(new ArSetCommand([key, index, ...values], this.commandOptions)); /** * @see https://redis.io/commands/bitcount * @see node_modules/@upstash/redis/docs/commands/bitmap/bitcount.mdx */ bitcount = (...args: CommandArgs) => this.chain(new BitCountCommand(args, this.commandOptions)); /** * Returns an instance that can be used to execute `BITFIELD` commands on one key. * * @example * ```typescript * redis.set("mykey", 0); * const result = await redis.pipeline() * .bitfield("mykey") * .set("u4", 0, 16) * .incr("u4", "#1", 1) * .exec(); * console.log(result); // [[0, 1]] * ``` * * @see https://redis.io/commands/bitfield */ bitfield = (...args: CommandArgs) => new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this)); /** * @see https://redis.io/commands/bitop * @see node_modules/@upstash/redis/docs/commands/bitmap/bitop.mdx */ bitop: { ( op: "and" | "or" | "xor", destinationKey: string, sourceKey: string, ...sourceKeys: string[] ): Pipeline<[...TCommands, BitOpCommand]>; (op: "not", destinationKey: string, sourceKey: string): Pipeline<[...TCommands, BitOpCommand]>; ( op: "diff" | "diff1" | "andor", destinationKey: string, x: string, ...y: string[] ): Pipeline<[...TCommands, BitOpCommand]>; ( op: "one", destinationKey: string, ...sourceKeys: string[] ): Pipeline<[...TCommands, BitOpCommand]>; } = ( op: "and" | "or" | "xor" | "not" | "diff" | "diff1" | "andor" | "one", destinationKey: string, sourceKey: string, ...sourceKeys: string[] ) => this.chain( new BitOpCommand([op as any, destinationKey, sourceKey, ...sourceKeys], this.commandOptions) ); /** * @see https://redis.io/commands/bitpos * @see node_modules/@upstash/redis/docs/commands/bitmap/bitpos.mdx */ bitpos = (...args: CommandArgs) => this.chain(new BitPosCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/client-setinfo * @see node_modules/@upstash/redis/docs/commands/connection/client_setinfo.mdx */ clientSetinfo = (...args: CommandArgs) => this.chain(new ClientSetInfoCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/copy */ copy = (...args: CommandArgs) => this.chain(new CopyCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zdiffstore * @see node_modules/@upstash/redis/docs/commands/zset/zdiffstore.mdx */ zdiffstore = (...args: CommandArgs) => this.chain(new ZDiffStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/dbsize * @see node_modules/@upstash/redis/docs/commands/server/dbsize.mdx */ dbsize = () => this.chain(new DBSizeCommand(this.commandOptions)); /** * @see https://redis.io/commands/decr * @see node_modules/@upstash/redis/docs/commands/string/decr.mdx */ decr = (...args: CommandArgs) => this.chain(new DecrCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/decrby * @see node_modules/@upstash/redis/docs/commands/string/decrby.mdx */ decrby = (...args: CommandArgs) => this.chain(new DecrByCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/del * @see node_modules/@upstash/redis/docs/commands/generic/del.mdx */ del = (...args: CommandArgs) => this.chain(new DelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/echo * @see node_modules/@upstash/redis/docs/commands/auth/echo.mdx */ echo = (...args: CommandArgs) => this.chain(new EchoCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/eval_ro * @see node_modules/@upstash/redis/docs/commands/scripts/eval_ro.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ evalRo = ( ...args: [script: string, keys: string[], args: TArgs] ) => this.chain(new EvalROCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/eval * @see node_modules/@upstash/redis/docs/commands/scripts/eval.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ eval = ( ...args: [script: string, keys: string[], args: TArgs] ) => this.chain(new EvalCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/evalsha_ro * @see node_modules/@upstash/redis/docs/commands/scripts/evalsha_ro.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ evalshaRo = ( ...args: [sha1: string, keys: string[], args: TArgs] ) => this.chain(new EvalshaROCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/evalsha * @see node_modules/@upstash/redis/docs/commands/scripts/evalsha.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ evalsha = ( ...args: [sha1: string, keys: string[], args: TArgs] ) => this.chain(new EvalshaCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/exists * @see node_modules/@upstash/redis/docs/commands/generic/exists.mdx */ exists = (...args: CommandArgs) => this.chain(new ExistsCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/expire * @see node_modules/@upstash/redis/docs/commands/generic/expire.mdx */ expire = (...args: CommandArgs) => this.chain(new ExpireCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/expireat * @see node_modules/@upstash/redis/docs/commands/generic/expireat.mdx */ expireat = (...args: CommandArgs) => this.chain(new ExpireAtCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/flushall * @see node_modules/@upstash/redis/docs/commands/server/flushall.mdx */ flushall = (args?: CommandArgs) => this.chain(new FlushAllCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/flushdb * @see node_modules/@upstash/redis/docs/commands/server/flushdb.mdx */ flushdb = (...args: CommandArgs) => this.chain(new FlushDBCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geoadd */ geoadd = (...args: CommandArgs>) => this.chain(new GeoAddCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geodist */ geodist = (...args: CommandArgs>) => this.chain(new GeoDistCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geopos */ geopos = (...args: CommandArgs>) => this.chain(new GeoPosCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geohash */ geohash = (...args: CommandArgs>) => this.chain(new GeoHashCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geosearch */ geosearch = (...args: CommandArgs>) => this.chain(new GeoSearchCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/geosearchstore */ geosearchstore = (...args: CommandArgs>) => this.chain(new GeoSearchStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/get * @see node_modules/@upstash/redis/docs/commands/string/get.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ get = (...args: CommandArgs) => this.chain(new GetCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/getbit * @see node_modules/@upstash/redis/docs/commands/bitmap/getbit.mdx */ getbit = (...args: CommandArgs) => this.chain(new GetBitCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/getdel * @see node_modules/@upstash/redis/docs/commands/string/getdel.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ getdel = (...args: CommandArgs) => this.chain(new GetDelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/getex * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ getex = (...args: CommandArgs) => this.chain(new GetExCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/getrange * @see node_modules/@upstash/redis/docs/commands/string/getrange.mdx */ getrange = (...args: CommandArgs) => this.chain(new GetRangeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/getset * @see node_modules/@upstash/redis/docs/commands/string/getset.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ getset = (key: string, value: TData) => this.chain(new GetSetCommand([key, value], this.commandOptions)); /** * @see https://redis.io/commands/hdel * @see node_modules/@upstash/redis/docs/commands/hash/hdel.mdx */ hdel = (...args: CommandArgs) => this.chain(new HDelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hexists * @see node_modules/@upstash/redis/docs/commands/hash/hexists.mdx */ hexists = (...args: CommandArgs) => this.chain(new HExistsCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hexpire * @see node_modules/@upstash/redis/docs/commands/hash/hexpire.mdx */ hexpire = (...args: CommandArgs) => this.chain(new HExpireCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hexpireat * @see node_modules/@upstash/redis/docs/commands/hash/hexpireat.mdx */ hexpireat = (...args: CommandArgs) => this.chain(new HExpireAtCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hexpiretime * @see node_modules/@upstash/redis/docs/commands/hash/hexpiretime.mdx */ hexpiretime = (...args: CommandArgs) => this.chain(new HExpireTimeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/httl * @see node_modules/@upstash/redis/docs/commands/hash/httl.mdx */ httl = (...args: CommandArgs) => this.chain(new HTtlCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hpexpire * @see node_modules/@upstash/redis/docs/commands/hash/hpexpire.mdx */ hpexpire = (...args: CommandArgs) => this.chain(new HPExpireCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hpexpireat * @see node_modules/@upstash/redis/docs/commands/hash/hpexpireat.mdx */ hpexpireat = (...args: CommandArgs) => this.chain(new HPExpireAtCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hpexpiretime * @see node_modules/@upstash/redis/docs/commands/hash/hpexpiretime.mdx */ hpexpiretime = (...args: CommandArgs) => this.chain(new HPExpireTimeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hpttl * @see node_modules/@upstash/redis/docs/commands/hash/hpttl.mdx */ hpttl = (...args: CommandArgs) => this.chain(new HPTtlCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hpersist * @see node_modules/@upstash/redis/docs/commands/hash/hpersist.mdx */ hpersist = (...args: CommandArgs) => this.chain(new HPersistCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hget * @see node_modules/@upstash/redis/docs/commands/hash/hget.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ hget = (...args: CommandArgs) => this.chain(new HGetCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hgetall * @see node_modules/@upstash/redis/docs/commands/hash/hgetall.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, hgetall returns a flat array instead, such as * ["text", "123", "version", "1"], and [] for a missing key. */ hgetall = >(...args: CommandArgs) => this.chain(new HGetAllCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hgetdel * @see node_modules/@upstash/redis/docs/commands/hash/hgetdel.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, hgetdel returns an array of values in field order instead, * such as ["123", null], with null for each field when the key is missing. */ hgetdel = >(...args: CommandArgs) => this.chain(new HGetDelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hgetex * @see node_modules/@upstash/redis/docs/commands/hash/hgetex.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, hgetex returns an array of values in field order instead, * such as ["123", null], with null for each field when the key is missing. */ hgetex = >(...args: CommandArgs) => this.chain(new HGetExCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hincrby * @see node_modules/@upstash/redis/docs/commands/hash/hincrby.mdx */ hincrby = (...args: CommandArgs) => this.chain(new HIncrByCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hincrbyfloat * @see node_modules/@upstash/redis/docs/commands/hash/hincrbyfloat.mdx */ hincrbyfloat = (...args: CommandArgs) => this.chain(new HIncrByFloatCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hkeys * @see node_modules/@upstash/redis/docs/commands/hash/hkeys.mdx */ hkeys = (...args: CommandArgs) => this.chain(new HKeysCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hlen * @see node_modules/@upstash/redis/docs/commands/hash/hlen.mdx */ hlen = (...args: CommandArgs) => this.chain(new HLenCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hmget * @see node_modules/@upstash/redis/docs/commands/hash/hmget.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, hmget returns an array of values in field order instead, * such as ["123", null], with null for each field when the key is missing. */ hmget = >(...args: CommandArgs) => this.chain(new HMGetCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hmset */ hmset = (key: string, kv: Record) => this.chain(new HMSetCommand([key, kv], this.commandOptions)); /** * @see https://redis.io/commands/hrandfield * @see node_modules/@upstash/redis/docs/commands/hash/hrandfield.mdx */ hrandfield = >( key: string, count?: number, withValues?: boolean ) => this.chain(new HRandFieldCommand([key, count, withValues] as any, this.commandOptions)); /** * @see https://redis.io/commands/hscan * @see node_modules/@upstash/redis/docs/commands/hash/hscan.mdx */ hscan = (...args: CommandArgs) => this.chain(new HScanCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hset * @see node_modules/@upstash/redis/docs/commands/hash/hset.mdx */ hset = (key: string, kv: Record) => this.chain(new HSetCommand([key, kv], this.commandOptions)); /** * @see https://redis.io/commands/hsetex * @see node_modules/@upstash/redis/docs/commands/hash/hsetex.mdx */ hsetex = (...args: CommandArgs>) => this.chain(new HSetExCommand(args as any, this.commandOptions)); /** * @see https://redis.io/commands/hsetnx * @see node_modules/@upstash/redis/docs/commands/hash/hsetnx.mdx */ hsetnx = (key: string, field: string, value: TData) => this.chain(new HSetNXCommand([key, field, value], this.commandOptions)); /** * @see https://redis.io/commands/hstrlen * @see node_modules/@upstash/redis/docs/commands/hash/hstrlen.mdx */ hstrlen = (...args: CommandArgs) => this.chain(new HStrLenCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/hvals * @see node_modules/@upstash/redis/docs/commands/hash/hvals.mdx */ hvals = (...args: CommandArgs) => this.chain(new HValsCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/incr * @see node_modules/@upstash/redis/docs/commands/string/incr.mdx */ incr = (...args: CommandArgs) => this.chain(new IncrCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/incrby * @see node_modules/@upstash/redis/docs/commands/string/incrby.mdx */ incrby = (...args: CommandArgs) => this.chain(new IncrByCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/incrbyfloat * @see node_modules/@upstash/redis/docs/commands/string/incrbyfloat.mdx */ incrbyfloat = (...args: CommandArgs) => this.chain(new IncrByFloatCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/keys * @see node_modules/@upstash/redis/docs/commands/generic/keys.mdx */ keys = (...args: CommandArgs) => this.chain(new KeysCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lindex * @see node_modules/@upstash/redis/docs/commands/list/lindex.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ lindex = (...args: CommandArgs) => this.chain(new LIndexCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/linsert * @see node_modules/@upstash/redis/docs/commands/list/linsert.mdx */ linsert = (key: string, direction: "before" | "after", pivot: TData, value: TData) => this.chain(new LInsertCommand([key, direction, pivot, value], this.commandOptions)); /** * @see https://redis.io/commands/llen * @see node_modules/@upstash/redis/docs/commands/list/llen.mdx */ llen = (...args: CommandArgs) => this.chain(new LLenCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lmove * @see node_modules/@upstash/redis/docs/commands/list/lmove.mdx */ lmove = (...args: CommandArgs) => this.chain(new LMoveCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lpop * @see node_modules/@upstash/redis/docs/commands/list/lpop.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ lpop = (...args: CommandArgs) => this.chain(new LPopCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lmpop */ lmpop = (...args: CommandArgs) => this.chain(new LmPopCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lpos * @see node_modules/@upstash/redis/docs/commands/list/lpos.mdx */ lpos = (...args: CommandArgs) => this.chain(new LPosCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lpush * @see node_modules/@upstash/redis/docs/commands/list/lpush.mdx */ lpush = (key: string, ...elements: TData[]) => this.chain(new LPushCommand([key, ...elements], this.commandOptions)); /** * @see https://redis.io/commands/lpushx * @see node_modules/@upstash/redis/docs/commands/list/lpushx.mdx */ lpushx = (key: string, ...elements: TData[]) => this.chain(new LPushXCommand([key, ...elements], this.commandOptions)); /** * @see https://redis.io/commands/lrange * @see node_modules/@upstash/redis/docs/commands/list/lrange.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ lrange = (...args: CommandArgs) => this.chain(new LRangeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/lrem * @see node_modules/@upstash/redis/docs/commands/list/lrem.mdx */ lrem = (key: string, count: number, value: TData) => this.chain(new LRemCommand([key, count, value], this.commandOptions)); /** * @see https://redis.io/commands/lset * @see node_modules/@upstash/redis/docs/commands/list/lset.mdx */ lset = (key: string, index: number, value: TData) => this.chain(new LSetCommand([key, index, value], this.commandOptions)); /** * @see https://redis.io/commands/ltrim * @see node_modules/@upstash/redis/docs/commands/list/ltrim.mdx */ ltrim = (...args: CommandArgs) => this.chain(new LTrimCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/mget * @see node_modules/@upstash/redis/docs/commands/string/mget.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ mget = (...args: CommandArgs) => this.chain(new MGetCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/mset * @see node_modules/@upstash/redis/docs/commands/string/mset.mdx */ mset = (kv: Record) => this.chain(new MSetCommand([kv], this.commandOptions)); /** * @see https://redis.io/commands/msetnx * @see node_modules/@upstash/redis/docs/commands/string/msetnx.mdx */ msetnx = (kv: Record) => this.chain(new MSetNXCommand([kv], this.commandOptions)); /** * @see https://redis.io/commands/persist * @see node_modules/@upstash/redis/docs/commands/generic/persist.mdx */ persist = (...args: CommandArgs) => this.chain(new PersistCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/pexpire * @see node_modules/@upstash/redis/docs/commands/generic/pexpire.mdx */ pexpire = (...args: CommandArgs) => this.chain(new PExpireCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/pexpireat * @see node_modules/@upstash/redis/docs/commands/generic/pexpireat.mdx */ pexpireat = (...args: CommandArgs) => this.chain(new PExpireAtCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/pfadd */ pfadd = (...args: CommandArgs) => this.chain(new PfAddCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/pfcount */ pfcount = (...args: CommandArgs) => this.chain(new PfCountCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/pfmerge */ pfmerge = (...args: CommandArgs) => this.chain(new PfMergeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/ping * @see node_modules/@upstash/redis/docs/commands/auth/ping.mdx */ ping = (args?: CommandArgs) => this.chain(new PingCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/psetex */ psetex = (key: string, ttl: number, value: TData) => this.chain(new PSetEXCommand([key, ttl, value], this.commandOptions)); /** * @see https://redis.io/commands/pttl * @see node_modules/@upstash/redis/docs/commands/generic/pttl.mdx */ pttl = (...args: CommandArgs) => this.chain(new PTtlCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/publish * @see node_modules/@upstash/redis/docs/commands/pubsub/publish.mdx */ publish = (...args: CommandArgs) => this.chain(new PublishCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/randomkey * @see node_modules/@upstash/redis/docs/commands/generic/randomkey.mdx */ randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions)); /** * @see https://redis.io/commands/rename * @see node_modules/@upstash/redis/docs/commands/generic/rename.mdx */ rename = (...args: CommandArgs) => this.chain(new RenameCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/renamenx * @see node_modules/@upstash/redis/docs/commands/generic/renamenx.mdx */ renamenx = (...args: CommandArgs) => this.chain(new RenameNXCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/rpop * @see node_modules/@upstash/redis/docs/commands/list/rpop.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ rpop = (...args: CommandArgs) => this.chain(new RPopCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/rpush * @see node_modules/@upstash/redis/docs/commands/list/rpush.mdx */ rpush = (key: string, ...elements: TData[]) => this.chain(new RPushCommand([key, ...elements], this.commandOptions)); /** * @see https://redis.io/commands/rpushx * @see node_modules/@upstash/redis/docs/commands/list/rpushx.mdx */ rpushx = (key: string, ...elements: TData[]) => this.chain(new RPushXCommand([key, ...elements], this.commandOptions)); /** * @see https://redis.io/commands/sadd * @see node_modules/@upstash/redis/docs/commands/set/sadd.mdx */ sadd = (key: string, member: TData, ...members: TData[]) => this.chain(new SAddCommand([key, member, ...members], this.commandOptions)); /** * @see https://redis.io/commands/scan * @see node_modules/@upstash/redis/docs/commands/generic/scan.mdx */ scan = (...args: CommandArgs) => this.chain(new ScanCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/scard * @see node_modules/@upstash/redis/docs/commands/set/scard.mdx */ scard = (...args: CommandArgs) => this.chain(new SCardCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/script-exists * @see node_modules/@upstash/redis/docs/commands/scripts/script_exists.mdx */ scriptExists = (...args: CommandArgs) => this.chain(new ScriptExistsCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/script-flush * @see node_modules/@upstash/redis/docs/commands/scripts/script_flush.mdx */ scriptFlush = (...args: CommandArgs) => this.chain(new ScriptFlushCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/script-load * @see node_modules/@upstash/redis/docs/commands/scripts/script_load.mdx */ scriptLoad = (...args: CommandArgs) => this.chain(new ScriptLoadCommand(args, this.commandOptions)); /*)* * @see https://redis.io/commands/sdiff * @see node_modules/@upstash/redis/docs/commands/set/sdiff.mdx */ sdiff = (...args: CommandArgs) => this.chain(new SDiffCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sdiffstore * @see node_modules/@upstash/redis/docs/commands/set/sdiffstore.mdx */ sdiffstore = (...args: CommandArgs) => this.chain(new SDiffStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/set * @see node_modules/@upstash/redis/docs/commands/string/set.mdx */ set = (key: string, value: TData, opts?: SetCommandOptions) => this.chain(new SetCommand([key, value, opts], this.commandOptions)); /** * @see https://redis.io/commands/setbit * @see node_modules/@upstash/redis/docs/commands/bitmap/setbit.mdx */ setbit = (...args: CommandArgs) => this.chain(new SetBitCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/setex */ setex = (key: string, ttl: number, value: TData) => this.chain(new SetExCommand([key, ttl, value], this.commandOptions)); /** * @see https://redis.io/commands/setnx */ setnx = (key: string, value: TData) => this.chain(new SetNxCommand([key, value], this.commandOptions)); /** * @see https://redis.io/commands/setrange * @see node_modules/@upstash/redis/docs/commands/string/setrange.mdx */ setrange = (...args: CommandArgs) => this.chain(new SetRangeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sinter * @see node_modules/@upstash/redis/docs/commands/set/sinter.mdx */ sinter = (...args: CommandArgs) => this.chain(new SInterCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sintercard */ sintercard = (...args: CommandArgs) => this.chain(new SInterCardCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sinterstore * @see node_modules/@upstash/redis/docs/commands/set/sinterstore.mdx */ sinterstore = (...args: CommandArgs) => this.chain(new SInterStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sismember * @see node_modules/@upstash/redis/docs/commands/set/sismember.mdx */ sismember = (key: string, member: TData) => this.chain(new SIsMemberCommand([key, member], this.commandOptions)); /** * @see https://redis.io/commands/smembers * @see node_modules/@upstash/redis/docs/commands/set/smembers.mdx */ smembers = (...args: CommandArgs) => this.chain(new SMembersCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/smismember * @see node_modules/@upstash/redis/docs/commands/set/smismember.mdx */ smismember = (key: string, members: TMembers) => this.chain(new SMIsMemberCommand([key, members], this.commandOptions)); /** * @see https://redis.io/commands/smove * @see node_modules/@upstash/redis/docs/commands/set/smove.mdx */ smove = (source: string, destination: string, member: TData) => this.chain(new SMoveCommand([source, destination, member], this.commandOptions)); /** * @see https://redis.io/commands/spop * @see node_modules/@upstash/redis/docs/commands/set/spop.mdx */ spop = (...args: CommandArgs) => this.chain(new SPopCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/srandmember * @see node_modules/@upstash/redis/docs/commands/set/srandmember.mdx */ srandmember = (...args: CommandArgs) => this.chain(new SRandMemberCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/srem * @see node_modules/@upstash/redis/docs/commands/set/srem.mdx */ srem = (key: string, ...members: TData[]) => this.chain(new SRemCommand([key, ...members], this.commandOptions)); /** * @see https://redis.io/commands/sscan * @see node_modules/@upstash/redis/docs/commands/set/sscan.mdx */ sscan = (...args: CommandArgs) => this.chain(new SScanCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/strlen * @see node_modules/@upstash/redis/docs/commands/string/strlen.mdx */ strlen = (...args: CommandArgs) => this.chain(new StrLenCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sunion * @see node_modules/@upstash/redis/docs/commands/set/sunion.mdx */ sunion = (...args: CommandArgs) => this.chain(new SUnionCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/sunionstore * @see node_modules/@upstash/redis/docs/commands/set/sunionstore.mdx */ sunionstore = (...args: CommandArgs) => this.chain(new SUnionStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/time */ time = () => this.chain(new TimeCommand(this.commandOptions)); /** * @see https://redis.io/commands/touch * @see node_modules/@upstash/redis/docs/commands/generic/touch.mdx */ touch = (...args: CommandArgs) => this.chain(new TouchCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/ttl * @see node_modules/@upstash/redis/docs/commands/generic/ttl.mdx */ ttl = (...args: CommandArgs) => this.chain(new TtlCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/type * @see node_modules/@upstash/redis/docs/commands/generic/type.mdx */ type = (...args: CommandArgs) => this.chain(new TypeCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/unlink * @see node_modules/@upstash/redis/docs/commands/generic/unlink.mdx */ unlink = (...args: CommandArgs) => this.chain(new UnlinkCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zadd * @see node_modules/@upstash/redis/docs/commands/zset/zadd.mdx */ zadd = ( ...args: | [key: string, scoreMember: ScoreMember, ...scoreMemberPairs: ScoreMember[]] | [ key: string, opts: ZAddCommandOptions, ...scoreMemberPairs: [ScoreMember, ...ScoreMember[]], ] ) => { if ("score" in args[1]) { return this.chain( new ZAddCommand([args[0], args[1], ...(args.slice(2) as any)], this.commandOptions) ); } return this.chain( new ZAddCommand( [args[0], args[1] as any, ...(args.slice(2) as any)], this.commandOptions ) ); }; /** * @see https://redis.io/commands/xadd * @see node_modules/@upstash/redis/docs/commands/stream/xadd.mdx */ xadd = (...args: CommandArgs) => this.chain(new XAddCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xack * @see node_modules/@upstash/redis/docs/commands/stream/xack.mdx */ xack = (...args: CommandArgs) => this.chain(new XAckCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xackdel * @see node_modules/@upstash/redis/docs/commands/stream/xackdel.mdx */ xackdel = (...args: CommandArgs) => this.chain(new XAckDelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xdel * @see node_modules/@upstash/redis/docs/commands/stream/xdel.mdx */ xdel = (...args: CommandArgs) => this.chain(new XDelCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xdelex * @see node_modules/@upstash/redis/docs/commands/stream/xdelex.mdx */ xdelex = (...args: CommandArgs) => this.chain(new XDelExCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xgroup * @see node_modules/@upstash/redis/docs/commands/stream/xgroup.mdx */ xgroup = (...args: CommandArgs) => this.chain(new XGroupCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xread * @see node_modules/@upstash/redis/docs/commands/stream/xread.mdx */ xread = (...args: CommandArgs) => this.chain(new XReadCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xreadgroup * @see node_modules/@upstash/redis/docs/commands/stream/xreadgroup.mdx */ xreadgroup = (...args: CommandArgs) => this.chain(new XReadGroupCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xinfo * @see node_modules/@upstash/redis/docs/commands/stream/xinfo.mdx */ xinfo = (...args: CommandArgs) => this.chain(new XInfoCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xlen * @see node_modules/@upstash/redis/docs/commands/stream/xlen.mdx */ xlen = (...args: CommandArgs) => this.chain(new XLenCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xpending * @see node_modules/@upstash/redis/docs/commands/stream/xpending.mdx */ xpending = (...args: CommandArgs) => this.chain(new XPendingCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xclaim * @see node_modules/@upstash/redis/docs/commands/stream/xclaim.mdx */ xclaim = (...args: CommandArgs) => this.chain(new XClaimCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xautoclaim * @see node_modules/@upstash/redis/docs/commands/stream/xautoclaim.mdx */ xautoclaim = (...args: CommandArgs) => this.chain(new XAutoClaim(args, this.commandOptions)); /** * @see https://redis.io/commands/xtrim * @see node_modules/@upstash/redis/docs/commands/stream/xtrim.mdx */ xtrim = (...args: CommandArgs) => this.chain(new XTrimCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/xrange * @see node_modules/@upstash/redis/docs/commands/stream/xrange.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, xrange returns [id, [field, value, ...]] entries instead, * such as [["1790341484470-0", ["text", "123"]]], and [] for a missing key. */ xrange = >(...args: CommandArgs) => this.chain(new XRangeCommand>(args, this.commandOptions)); /** * @see https://redis.io/commands/xrevrange * @see node_modules/@upstash/redis/docs/commands/stream/xrevrange.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. * With automaticDeserialization: false, xrevrange returns [id, [field, value, ...]] entries instead, * such as [["1790341484470-0", ["text", "123"]]], and [] for a missing key. */ xrevrange = >( ...args: CommandArgs ) => this.chain(new XRevRangeCommand>(args, this.commandOptions)); /** * @see https://redis.io/commands/zcard * @see node_modules/@upstash/redis/docs/commands/zset/zcard.mdx */ zcard = (...args: CommandArgs) => this.chain(new ZCardCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zcount * @see node_modules/@upstash/redis/docs/commands/zset/zcount.mdx */ zcount = (...args: CommandArgs) => this.chain(new ZCountCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zincrby * @see node_modules/@upstash/redis/docs/commands/zset/zincrby.mdx */ zincrby = (key: string, increment: number, member: TData) => this.chain(new ZIncrByCommand([key, increment, member], this.commandOptions)); /** * @see https://redis.io/commands/zinterstore * @see node_modules/@upstash/redis/docs/commands/zset/zinterstore.mdx */ zinterstore = (...args: CommandArgs) => this.chain(new ZInterStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zlexcount * @see node_modules/@upstash/redis/docs/commands/zset/zlexcount.mdx */ zlexcount = (...args: CommandArgs) => this.chain(new ZLexCountCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zmscore * @see node_modules/@upstash/redis/docs/commands/zset/zmscore.mdx */ zmscore = (...args: CommandArgs) => this.chain(new ZMScoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zpopmax * @see node_modules/@upstash/redis/docs/commands/zset/zpopmax.mdx */ zpopmax = (...args: CommandArgs) => this.chain(new ZPopMaxCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zpopmin * @see node_modules/@upstash/redis/docs/commands/zset/zpopmin.mdx */ zpopmin = (...args: CommandArgs) => this.chain(new ZPopMinCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zrange * @see node_modules/@upstash/redis/docs/commands/zset/zrange.mdx * Responses are JSON-parsed automatically: a stored "123" comes back as the number 123, "true" as * true, and '{"a":1}' as an object. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ zrange = ( ...args: | [key: string, min: number, max: number, opts?: ZRangeCommandOptions] | [ key: string, min: `(${string}` | `[${string}` | "-" | "+", max: `(${string}` | `[${string}` | "-" | "+", opts: { byLex: true } & ZRangeCommandOptions, ] | [ key: string, min: number | `(${number}` | "-inf" | "+inf", max: number | `(${number}` | "-inf" | "+inf", opts: { byScore: true } & ZRangeCommandOptions, ] ) => this.chain(new ZRangeCommand(args as any, this.commandOptions)); /** * @see https://redis.io/commands/zrank * @see node_modules/@upstash/redis/docs/commands/zset/zrank.mdx */ zrank = (key: string, member: TData) => this.chain(new ZRankCommand([key, member], this.commandOptions)); /** * @see https://redis.io/commands/zrem * @see node_modules/@upstash/redis/docs/commands/zset/zrem.mdx */ zrem = (key: string, ...members: TData[]) => this.chain(new ZRemCommand([key, ...members], this.commandOptions)); /** * @see https://redis.io/commands/zremrangebylex * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebylex.mdx */ zremrangebylex = (...args: CommandArgs) => this.chain(new ZRemRangeByLexCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zremrangebyrank * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebyrank.mdx */ zremrangebyrank = (...args: CommandArgs) => this.chain(new ZRemRangeByRankCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zremrangebyscore * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebyscore.mdx */ zremrangebyscore = (...args: CommandArgs) => this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zrevrank * @see node_modules/@upstash/redis/docs/commands/zset/zrevrank.mdx */ zrevrank = (key: string, member: TData) => this.chain(new ZRevRankCommand([key, member], this.commandOptions)); /** * @see https://redis.io/commands/zscan * @see node_modules/@upstash/redis/docs/commands/zset/zscan.mdx */ zscan = (...args: CommandArgs) => this.chain(new ZScanCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zscore * @see node_modules/@upstash/redis/docs/commands/zset/zscore.mdx */ zscore = (key: string, member: TData) => this.chain(new ZScoreCommand([key, member], this.commandOptions)); /** * @see https://redis.io/commands/zunionstore * @see node_modules/@upstash/redis/docs/commands/zset/zunionstore.mdx */ zunionstore = (...args: CommandArgs) => this.chain(new ZUnionStoreCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/zunion */ zunion = (...args: CommandArgs) => this.chain(new ZUnionCommand(args, this.commandOptions)); /** * @see https://redis.io/commands/?group=json */ get json() { return { /** * @see https://redis.io/commands/json.arrappend * @see node_modules/@upstash/redis/docs/commands/json/arrappend.mdx */ arrappend: (...args: CommandArgs) => this.chain(new JsonArrAppendCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.arrindex * @see node_modules/@upstash/redis/docs/commands/json/arrindex.mdx */ arrindex: (...args: CommandArgs) => this.chain(new JsonArrIndexCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.arrinsert * @see node_modules/@upstash/redis/docs/commands/json/arrinsert.mdx */ arrinsert: (...args: CommandArgs) => this.chain(new JsonArrInsertCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.arrlen * @see node_modules/@upstash/redis/docs/commands/json/arrlen.mdx */ arrlen: (...args: CommandArgs) => this.chain(new JsonArrLenCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.arrpop * @see node_modules/@upstash/redis/docs/commands/json/arrpop.mdx */ arrpop: (...args: CommandArgs) => this.chain(new JsonArrPopCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.arrtrim * @see node_modules/@upstash/redis/docs/commands/json/arrtrim.mdx */ arrtrim: (...args: CommandArgs) => this.chain(new JsonArrTrimCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.clear * @see node_modules/@upstash/redis/docs/commands/json/clear.mdx */ clear: (...args: CommandArgs) => this.chain(new JsonClearCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.del * @see node_modules/@upstash/redis/docs/commands/json/del.mdx */ del: (...args: CommandArgs) => this.chain(new JsonDelCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.forget * @see node_modules/@upstash/redis/docs/commands/json/forget.mdx */ forget: (...args: CommandArgs) => this.chain(new JsonForgetCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.get * @see node_modules/@upstash/redis/docs/commands/json/get.mdx */ get: (...args: CommandArgs) => this.chain(new JsonGetCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.merge * @see node_modules/@upstash/redis/docs/commands/json/merge.mdx */ merge: (...args: CommandArgs) => this.chain(new JsonMergeCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.mget * @see node_modules/@upstash/redis/docs/commands/json/mget.mdx */ mget: (...args: CommandArgs) => this.chain(new JsonMGetCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.mset * @see node_modules/@upstash/redis/docs/commands/json/mset.mdx */ mset: (...args: CommandArgs) => this.chain(new JsonMSetCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.numincrby * @see node_modules/@upstash/redis/docs/commands/json/numincrby.mdx */ numincrby: (...args: CommandArgs) => this.chain(new JsonNumIncrByCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.nummultby * @see node_modules/@upstash/redis/docs/commands/json/nummultby.mdx */ nummultby: (...args: CommandArgs) => this.chain(new JsonNumMultByCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.objkeys * @see node_modules/@upstash/redis/docs/commands/json/objkeys.mdx */ objkeys: (...args: CommandArgs) => this.chain(new JsonObjKeysCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.objlen * @see node_modules/@upstash/redis/docs/commands/json/objlen.mdx */ objlen: (...args: CommandArgs) => this.chain(new JsonObjLenCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.resp */ resp: (...args: CommandArgs) => this.chain(new JsonRespCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.set * @see node_modules/@upstash/redis/docs/commands/json/set.mdx */ set: (...args: CommandArgs) => this.chain(new JsonSetCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.strappend * @see node_modules/@upstash/redis/docs/commands/json/strappend.mdx */ strappend: (...args: CommandArgs) => this.chain(new JsonStrAppendCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.strlen * @see node_modules/@upstash/redis/docs/commands/json/strlen.mdx */ strlen: (...args: CommandArgs) => this.chain(new JsonStrLenCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.toggle * @see node_modules/@upstash/redis/docs/commands/json/toggle.mdx */ toggle: (...args: CommandArgs) => this.chain(new JsonToggleCommand(args, this.commandOptions)), /** * @see https://redis.io/commands/json.type * @see node_modules/@upstash/redis/docs/commands/json/type.mdx */ type: (...args: CommandArgs) => this.chain(new JsonTypeCommand(args, this.commandOptions)), }; } get functions() { return { /** * @see https://redis.io/docs/latest/commands/function-load/ * @see node_modules/@upstash/redis/docs/commands/functions/load.mdx */ load: (...args: CommandArgs) => this.chain(new FunctionLoadCommand(args, this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/function-list/ * @see node_modules/@upstash/redis/docs/commands/functions/list.mdx */ list: (...args: CommandArgs) => this.chain(new FunctionListCommand(args, this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/function-delete/ * @see node_modules/@upstash/redis/docs/commands/functions/delete.mdx */ delete: (...args: CommandArgs) => this.chain(new FunctionDeleteCommand(args, this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/function-flush/ * @see node_modules/@upstash/redis/docs/commands/functions/flush.mdx */ flush: () => this.chain(new FunctionFlushCommand(this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/function-stats/ * @see node_modules/@upstash/redis/docs/commands/functions/stats.mdx */ stats: () => this.chain(new FunctionStatsCommand(this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/fcall/ * @see node_modules/@upstash/redis/docs/commands/functions/call.mdx */ call: (...args: CommandArgs>) => this.chain(new FCallCommand(args, this.commandOptions)), /** * @see https://redis.io/docs/latest/commands/fcall_ro/ * @see node_modules/@upstash/redis/docs/commands/functions/call_ro.mdx */ callRo: (...args: CommandArgs>) => this.chain(new FCallRoCommand(args, this.commandOptions)), }; } }