import { createAutoPipelineProxy } from "../pkg/auto-pipeline"; import type { CommandOptions, ScoreMember, SetCommandOptions, ZAddCommandOptions, ZRangeCommandOptions, ScanCommandOptions, ScanResultStandard, ScanResultWithType, } 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, ExecCommand, 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, HRandFieldCommand, 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 { type CreateIndexParameters, type NestedIndexSchema, type FlatIndexSchema, } from "./commands/search"; import type { InitIndexParameters } from "./commands/search/search"; import { createIndex, initIndex, listAliases, addAlias, delAlias } from "./commands/search/search"; import type { CreateVectorIndexParameters } from "./commands/vector/vector"; import { createVectorIndex, initVectorIndex } from "./commands/vector/vector"; import { Subscriber } from "./commands/subscribe"; import { ZDiffStoreCommand } from "./commands/zdiffstore"; import { ZMScoreCommand } from "./commands/zmscore"; import type { Requester, UpstashRequest, UpstashResponse } from "./http"; import { Pipeline } from "./pipeline"; import { Script } from "./script"; import { ScriptRO } from "./scriptRo"; import type { CommandArgs, RedisOptions, Telemetry } from "./types"; // See https://github.com/upstash/upstash-redis/issues/342 // why we need this export export type { RedisOptions } from "./types"; /** * Serverless redis client for upstash. */ export class Redis { protected client: Requester; protected opts?: CommandOptions; protected enableTelemetry: boolean; protected enableAutoPipelining: boolean; /** * Create a new redis client * * @example * ```typescript * const redis = new Redis({ * url: "", * token: "", * }); * ``` */ constructor(client: Requester, opts?: RedisOptions) { this.client = client; this.opts = opts; this.enableTelemetry = opts?.enableTelemetry ?? true; if (opts?.readYourWrites === false) { this.client.readYourWrites = false; } this.enableAutoPipelining = opts?.enableAutoPipelining ?? true; } get readYourWritesSyncToken(): string | undefined { return this.client.upstashSyncToken; } set readYourWritesSyncToken(session: string | undefined) { this.client.upstashSyncToken = session; } get json() { return { /** * @see https://redis.io/commands/json.arrappend * @see node_modules/@upstash/redis/docs/commands/json/arrappend.mdx */ arrappend: (...args: CommandArgs) => new JsonArrAppendCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.arrindex * @see node_modules/@upstash/redis/docs/commands/json/arrindex.mdx */ arrindex: (...args: CommandArgs) => new JsonArrIndexCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.arrinsert * @see node_modules/@upstash/redis/docs/commands/json/arrinsert.mdx */ arrinsert: (...args: CommandArgs) => new JsonArrInsertCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.arrlen * @see node_modules/@upstash/redis/docs/commands/json/arrlen.mdx */ arrlen: (...args: CommandArgs) => new JsonArrLenCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.arrpop * @see node_modules/@upstash/redis/docs/commands/json/arrpop.mdx */ arrpop: (...args: CommandArgs) => new JsonArrPopCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.arrtrim * @see node_modules/@upstash/redis/docs/commands/json/arrtrim.mdx */ arrtrim: (...args: CommandArgs) => new JsonArrTrimCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.clear * @see node_modules/@upstash/redis/docs/commands/json/clear.mdx */ clear: (...args: CommandArgs) => new JsonClearCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.del * @see node_modules/@upstash/redis/docs/commands/json/del.mdx */ del: (...args: CommandArgs) => new JsonDelCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.forget * @see node_modules/@upstash/redis/docs/commands/json/forget.mdx */ forget: (...args: CommandArgs) => new JsonForgetCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.get * @see node_modules/@upstash/redis/docs/commands/json/get.mdx */ get: (...args: CommandArgs) => new JsonGetCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.merge * @see node_modules/@upstash/redis/docs/commands/json/merge.mdx */ merge: (...args: CommandArgs) => new JsonMergeCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.mget * @see node_modules/@upstash/redis/docs/commands/json/mget.mdx */ mget: (...args: CommandArgs) => new JsonMGetCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.mset * @see node_modules/@upstash/redis/docs/commands/json/mset.mdx */ mset: (...args: CommandArgs) => new JsonMSetCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.numincrby * @see node_modules/@upstash/redis/docs/commands/json/numincrby.mdx */ numincrby: (...args: CommandArgs) => new JsonNumIncrByCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.nummultby * @see node_modules/@upstash/redis/docs/commands/json/nummultby.mdx */ nummultby: (...args: CommandArgs) => new JsonNumMultByCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.objkeys * @see node_modules/@upstash/redis/docs/commands/json/objkeys.mdx */ objkeys: (...args: CommandArgs) => new JsonObjKeysCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.objlen * @see node_modules/@upstash/redis/docs/commands/json/objlen.mdx */ objlen: (...args: CommandArgs) => new JsonObjLenCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.resp */ resp: (...args: CommandArgs) => new JsonRespCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.set * @see node_modules/@upstash/redis/docs/commands/json/set.mdx */ set: (...args: CommandArgs) => new JsonSetCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.strappend * @see node_modules/@upstash/redis/docs/commands/json/strappend.mdx */ strappend: (...args: CommandArgs) => new JsonStrAppendCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.strlen * @see node_modules/@upstash/redis/docs/commands/json/strlen.mdx */ strlen: (...args: CommandArgs) => new JsonStrLenCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.toggle * @see node_modules/@upstash/redis/docs/commands/json/toggle.mdx */ toggle: (...args: CommandArgs) => new JsonToggleCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/commands/json.type * @see node_modules/@upstash/redis/docs/commands/json/type.mdx */ type: (...args: CommandArgs) => new JsonTypeCommand(args, this.opts).exec(this.client), }; } 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) => new FunctionLoadCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/function-list/ * @see node_modules/@upstash/redis/docs/commands/functions/list.mdx */ list: (...args: CommandArgs) => new FunctionListCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/function-delete/ * @see node_modules/@upstash/redis/docs/commands/functions/delete.mdx */ delete: (...args: CommandArgs) => new FunctionDeleteCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/function-flush/ * @see node_modules/@upstash/redis/docs/commands/functions/flush.mdx */ flush: () => new FunctionFlushCommand(this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/function-stats/ * @see node_modules/@upstash/redis/docs/commands/functions/stats.mdx * * Note: `running_script` field is not supported and therefore not included in the type. */ stats: () => new FunctionStatsCommand(this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/fcall/ * @see node_modules/@upstash/redis/docs/commands/functions/call.mdx */ call: (...args: CommandArgs>) => new FCallCommand(args, this.opts).exec(this.client), /** * @see https://redis.io/docs/latest/commands/fcall_ro/ * @see node_modules/@upstash/redis/docs/commands/functions/call_ro.mdx */ callRo: (...args: CommandArgs>) => new FCallRoCommand(args, this.opts).exec(this.client), }; } /** * Wrap a new middleware around the HTTP client. */ use = ( middleware: ( r: UpstashRequest, next: (req: UpstashRequest) => Promise> ) => Promise> ) => { const makeRequest = this.client.request.bind(this.client); this.client.request = (req: UpstashRequest) => middleware(req, makeRequest) as any; }; /** * Technically this is not private, we can hide it from intellisense by doing this */ protected addTelemetry = (telemetry: Telemetry) => { if (!this.enableTelemetry) { return; } try { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - The `Requester` interface does not know about this method but it will be there // as long as the user uses the standard HttpClient this.client.mergeTelemetry(telemetry); } catch { // ignore } }; /** * Creates a new script. * * Scripts offer the ability to optimistically try to execute a script without having to send the * entire script to the server. If the script is loaded on the server, it tries again by sending * the entire script. Afterwards, the script is cached on the server. * * 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. * * @param script - The script to create * @param opts - Optional options to pass to the script `{ readonly?: boolean }` * @returns A new script * * @example * ```ts * const redis = new Redis({...}) * * const script = redis.createScript("return ARGV[1];") * const arg1 = await script.eval([], ["Hello World"]) * expect(arg1, "Hello World") * ``` * @example * ```ts * const redis = new Redis({...}) * * const script = redis.createScript("return ARGV[1];", { readonly: true }) * const arg1 = await script.evalRo([], ["Hello World"]) * expect(arg1, "Hello World") * ``` */ createScript( script: string, opts?: { readonly?: TReadonly } ): TReadonly extends true ? ScriptRO : Script { return opts?.readonly ? (new ScriptRO(this, script) as any) : (new Script(this, script) as any); } get search() { return { createIndex: ( params: CreateIndexParameters ) => { return createIndex(this.client, params); }, index: ( params: InitIndexParameters ) => { return initIndex(this.client, params); }, alias: { list: () => { return listAliases(this.client); }, add: ({ indexName, alias }: { indexName: string; alias: string }) => { return addAlias(this.client, { indexName, alias }); }, delete: ({ alias }: { alias: string }) => { return delAlias(this.client, { alias }); }, }, }; } /** * Vector index commands. * * @example * ```typescript * const index = await redis.vector.createIndex({ name: "docs", dimension: 3, metric: "COSINE" }); * await index.add("doc-1", [0.1, 0.2, 0.3]); * const hits = await index.query({ vector: [0.1, 0.2, 0.3], topK: 5 }); * ``` */ get vector() { return { /** * Creates a vector index and returns a handle to it. */ createIndex: (params: CreateVectorIndexParameters) => { return createVectorIndex(this.client, params, this.opts); }, /** * Returns a handle to an existing vector index without sending any command. */ index: (name: string) => { return initVectorIndex(this.client, name, this.opts); }, }; } /** * Create a new pipeline that allows you to send requests in bulk. * * @see {@link Pipeline} */ pipeline = () => new Pipeline({ client: this.client, commandOptions: this.opts, multiExec: false, }); protected autoPipeline = () => { return createAutoPipelineProxy(this); }; /** * Create a new transaction to allow executing multiple steps atomically. * * All the commands in a transaction are serialized and executed sequentially. A request sent by * another client will never be served in the middle of the execution of a Redis Transaction. This * guarantees that the commands are executed as a single isolated operation. * * @see {@link Pipeline} */ multi = () => new Pipeline({ client: this.client, commandOptions: this.opts, multiExec: true, }); /** * Returns an instance that can be used to execute `BITFIELD` commands on one key. * * @example * ```typescript * redis.set("mykey", 0); * const result = await redis.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.opts); /** * @see https://redis.io/commands/append * @see node_modules/@upstash/redis/docs/commands/string/append.mdx */ append = (...args: CommandArgs) => new AppendCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arcount * @see node_modules/@upstash/redis/docs/commands/array/arcount.mdx */ arcount = (...args: CommandArgs) => new ArCountCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/ardel * @see node_modules/@upstash/redis/docs/commands/array/ardel.mdx */ ardel = (...args: CommandArgs) => new ArDelCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/ardelrange * @see node_modules/@upstash/redis/docs/commands/array/ardelrange.mdx */ ardelrange = (...args: CommandArgs) => new ArDelRangeCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arget * @see node_modules/@upstash/redis/docs/commands/array/arget.mdx */ arget = (...args: CommandArgs) => new ArGetCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/argetrange * @see node_modules/@upstash/redis/docs/commands/array/argetrange.mdx */ argetrange = (...args: CommandArgs) => new ArGetRangeCommand(args, this.opts).exec(this.client); /** * @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 ) => new ArGrepCommand([key, start, end, opts], this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arinfo * @see node_modules/@upstash/redis/docs/commands/array/arinfo.mdx */ arinfo = (...args: CommandArgs) => new ArInfoCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arinsert * @see node_modules/@upstash/redis/docs/commands/array/arinsert.mdx */ arinsert = (key: string, ...values: TData[]) => new ArInsertCommand([key, ...values], this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arlastitems * @see node_modules/@upstash/redis/docs/commands/array/arlastitems.mdx */ arlastitems = (...args: CommandArgs) => new ArLastItemsCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arlen * @see node_modules/@upstash/redis/docs/commands/array/arlen.mdx */ arlen = (...args: CommandArgs) => new ArLenCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/armget * @see node_modules/@upstash/redis/docs/commands/array/armget.mdx */ armget = (...args: CommandArgs) => new ArMGetCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/armset * @see node_modules/@upstash/redis/docs/commands/array/armset.mdx */ armset = (key: string, values: ArMSetValues) => new ArMSetCommand([key, values], this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arnext * @see node_modules/@upstash/redis/docs/commands/array/arnext.mdx */ arnext = (...args: CommandArgs) => new ArNextCommand(args, this.opts).exec(this.client); /** * @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 ) => new ArOpCommand([key, start, end, operation], this.opts).exec(this.client); /** * @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[]) => new ArRingCommand([key, size, ...values], this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arscan * @see node_modules/@upstash/redis/docs/commands/array/arscan.mdx */ arscan = (...args: CommandArgs) => new ArScanCommand(args, this.opts).exec(this.client); /** * @see https://upstash.com/docs/redis/commands/array/arseek * @see node_modules/@upstash/redis/docs/commands/array/arseek.mdx */ arseek = (...args: CommandArgs) => new ArSeekCommand(args, this.opts).exec(this.client); /** * @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[]) => new ArSetCommand([key, index, ...values], this.opts).exec(this.client); /** * @see https://redis.io/commands/bitcount * @see node_modules/@upstash/redis/docs/commands/bitmap/bitcount.mdx */ bitcount = (...args: CommandArgs) => new BitCountCommand(args, this.opts).exec(this.client); /** * @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[] ): Promise; (op: "not", destinationKey: string, sourceKey: string): Promise; ( op: "diff" | "diff1" | "andor", destinationKey: string, x: string, ...y: string[] ): Promise; (op: "one", destinationKey: string, ...sourceKeys: string[]): Promise; } = ( op: "and" | "or" | "xor" | "not" | "diff" | "diff1" | "andor" | "one", destinationKey: string, sourceKey: string, ...sourceKeys: string[] ) => new BitOpCommand([op as any, destinationKey, sourceKey, ...sourceKeys], this.opts).exec( this.client ); /** * @see https://redis.io/commands/bitpos * @see node_modules/@upstash/redis/docs/commands/bitmap/bitpos.mdx */ bitpos = (...args: CommandArgs) => new BitPosCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/client-setinfo * @see node_modules/@upstash/redis/docs/commands/connection/client_setinfo.mdx */ clientSetinfo = (...args: CommandArgs) => new ClientSetInfoCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/copy */ copy = (...args: CommandArgs) => new CopyCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/dbsize * @see node_modules/@upstash/redis/docs/commands/server/dbsize.mdx */ dbsize = () => new DBSizeCommand(this.opts).exec(this.client); /** * @see https://redis.io/commands/decr * @see node_modules/@upstash/redis/docs/commands/string/decr.mdx */ decr = (...args: CommandArgs) => new DecrCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/decrby * @see node_modules/@upstash/redis/docs/commands/string/decrby.mdx */ decrby = (...args: CommandArgs) => new DecrByCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/del * @see node_modules/@upstash/redis/docs/commands/generic/del.mdx */ del = (...args: CommandArgs) => new DelCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/echo * @see node_modules/@upstash/redis/docs/commands/auth/echo.mdx */ echo = (...args: CommandArgs) => new EchoCommand(args, this.opts).exec(this.client); /** * @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] ) => new EvalROCommand(args, this.opts).exec(this.client); /** * @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] ) => new EvalCommand(args, this.opts).exec(this.client); /** * @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] ) => new EvalshaROCommand(args, this.opts).exec(this.client); /** * @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] ) => new EvalshaCommand(args, this.opts).exec(this.client); /** * Generic method to execute any Redis command. */ exec = (args: [command: string, ...args: (string | number | boolean)[]]) => new ExecCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/exists * @see node_modules/@upstash/redis/docs/commands/generic/exists.mdx */ exists = (...args: CommandArgs) => new ExistsCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/expire * @see node_modules/@upstash/redis/docs/commands/generic/expire.mdx */ expire = (...args: CommandArgs) => new ExpireCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/expireat * @see node_modules/@upstash/redis/docs/commands/generic/expireat.mdx */ expireat = (...args: CommandArgs) => new ExpireAtCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/flushall * @see node_modules/@upstash/redis/docs/commands/server/flushall.mdx */ flushall = (args?: CommandArgs) => new FlushAllCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/flushdb * @see node_modules/@upstash/redis/docs/commands/server/flushdb.mdx */ flushdb = (...args: CommandArgs) => new FlushDBCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geoadd */ geoadd = (...args: CommandArgs>) => new GeoAddCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geopos */ geopos = (...args: CommandArgs>) => new GeoPosCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geodist */ geodist = (...args: CommandArgs>) => new GeoDistCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geohash */ geohash = (...args: CommandArgs>) => new GeoHashCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geosearch */ geosearch = (...args: CommandArgs>) => new GeoSearchCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/geosearchstore */ geosearchstore = (...args: CommandArgs>) => new GeoSearchStoreCommand(args, this.opts).exec(this.client); /** * @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) => new GetCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/getbit * @see node_modules/@upstash/redis/docs/commands/bitmap/getbit.mdx */ getbit = (...args: CommandArgs) => new GetBitCommand(args, this.opts).exec(this.client); /** * @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) => new GetDelCommand(args, this.opts).exec(this.client); /** * @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) => new GetExCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/getrange * @see node_modules/@upstash/redis/docs/commands/string/getrange.mdx */ getrange = (...args: CommandArgs) => new GetRangeCommand(args, this.opts).exec(this.client); /** * @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) => new GetSetCommand([key, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/hdel * @see node_modules/@upstash/redis/docs/commands/hash/hdel.mdx */ hdel = (...args: CommandArgs) => new HDelCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hexists * @see node_modules/@upstash/redis/docs/commands/hash/hexists.mdx */ hexists = (...args: CommandArgs) => new HExistsCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hexpire * @see node_modules/@upstash/redis/docs/commands/hash/hexpire.mdx */ hexpire = (...args: CommandArgs) => new HExpireCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hexpireat * @see node_modules/@upstash/redis/docs/commands/hash/hexpireat.mdx */ hexpireat = (...args: CommandArgs) => new HExpireAtCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hexpiretime * @see node_modules/@upstash/redis/docs/commands/hash/hexpiretime.mdx */ hexpiretime = (...args: CommandArgs) => new HExpireTimeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/httl * @see node_modules/@upstash/redis/docs/commands/hash/httl.mdx */ httl = (...args: CommandArgs) => new HTtlCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hpexpire * @see node_modules/@upstash/redis/docs/commands/hash/hpexpire.mdx */ hpexpire = (...args: CommandArgs) => new HPExpireCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hpexpireat * @see node_modules/@upstash/redis/docs/commands/hash/hpexpireat.mdx */ hpexpireat = (...args: CommandArgs) => new HPExpireAtCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hpexpiretime * @see node_modules/@upstash/redis/docs/commands/hash/hpexpiretime.mdx */ hpexpiretime = (...args: CommandArgs) => new HPExpireTimeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hpttl * @see node_modules/@upstash/redis/docs/commands/hash/hpttl.mdx */ hpttl = (...args: CommandArgs) => new HPTtlCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hpersist * @see node_modules/@upstash/redis/docs/commands/hash/hpersist.mdx */ hpersist = (...args: CommandArgs) => new HPersistCommand(args, this.opts).exec(this.client); /** * @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) => new HGetCommand(args, this.opts).exec(this.client); /** * @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) => new HGetAllCommand(args, this.opts).exec(this.client); /** * @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) => new HGetDelCommand(args, this.opts).exec(this.client); /** * @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) => new HGetExCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hincrby * @see node_modules/@upstash/redis/docs/commands/hash/hincrby.mdx */ hincrby = (...args: CommandArgs) => new HIncrByCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hincrbyfloat * @see node_modules/@upstash/redis/docs/commands/hash/hincrbyfloat.mdx */ hincrbyfloat = (...args: CommandArgs) => new HIncrByFloatCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hkeys * @see node_modules/@upstash/redis/docs/commands/hash/hkeys.mdx */ hkeys = (...args: CommandArgs) => new HKeysCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hlen * @see node_modules/@upstash/redis/docs/commands/hash/hlen.mdx */ hlen = (...args: CommandArgs) => new HLenCommand(args, this.opts).exec(this.client); /** * @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) => new HMGetCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hmset */ hmset = (key: string, kv: Record) => new HMSetCommand([key, kv], this.opts).exec(this.client); /** * @see https://redis.io/commands/hrandfield * @see node_modules/@upstash/redis/docs/commands/hash/hrandfield.mdx */ hrandfield: { (key: string): Promise; (key: string, count: number): Promise; >( key: string, count: number, withValues: boolean ): Promise>; } = >( key: string, count?: number, withValues?: boolean ) => new HRandFieldCommand([key, count, withValues] as any, this.opts).exec(this.client); /** * @see https://redis.io/commands/hscan * @see node_modules/@upstash/redis/docs/commands/hash/hscan.mdx */ hscan = (...args: CommandArgs) => new HScanCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hset * @see node_modules/@upstash/redis/docs/commands/hash/hset.mdx */ hset = (key: string, kv: Record) => new HSetCommand([key, kv], this.opts).exec(this.client); /** * @see https://redis.io/commands/hsetex * @see node_modules/@upstash/redis/docs/commands/hash/hsetex.mdx */ hsetex = (...args: CommandArgs>) => new HSetExCommand(args as any, this.opts).exec(this.client); /** * @see https://redis.io/commands/hsetnx * @see node_modules/@upstash/redis/docs/commands/hash/hsetnx.mdx */ hsetnx = (key: string, field: string, value: TData) => new HSetNXCommand([key, field, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/hstrlen * @see node_modules/@upstash/redis/docs/commands/hash/hstrlen.mdx */ hstrlen = (...args: CommandArgs) => new HStrLenCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/hvals * @see node_modules/@upstash/redis/docs/commands/hash/hvals.mdx */ hvals = (...args: CommandArgs) => new HValsCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/incr * @see node_modules/@upstash/redis/docs/commands/string/incr.mdx */ incr = (...args: CommandArgs) => new IncrCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/incrby * @see node_modules/@upstash/redis/docs/commands/string/incrby.mdx */ incrby = (...args: CommandArgs) => new IncrByCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/incrbyfloat * @see node_modules/@upstash/redis/docs/commands/string/incrbyfloat.mdx */ incrbyfloat = (...args: CommandArgs) => new IncrByFloatCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/keys * @see node_modules/@upstash/redis/docs/commands/generic/keys.mdx */ keys = (...args: CommandArgs) => new KeysCommand(args, this.opts).exec(this.client); /** * @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) => new LIndexCommand(args, this.opts).exec(this.client); /** * @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) => new LInsertCommand([key, direction, pivot, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/llen * @see node_modules/@upstash/redis/docs/commands/list/llen.mdx */ llen = (...args: CommandArgs) => new LLenCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/lmove * @see node_modules/@upstash/redis/docs/commands/list/lmove.mdx */ lmove = (...args: CommandArgs) => new LMoveCommand(args, this.opts).exec(this.client); /** * @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) => new LPopCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/lmpop */ lmpop = (...args: CommandArgs) => new LmPopCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/lpos * @see node_modules/@upstash/redis/docs/commands/list/lpos.mdx */ lpos = (...args: CommandArgs) => new LPosCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/lpush * @see node_modules/@upstash/redis/docs/commands/list/lpush.mdx */ lpush = (key: string, ...elements: TData[]) => new LPushCommand([key, ...elements], this.opts).exec(this.client); /** * @see https://redis.io/commands/lpushx * @see node_modules/@upstash/redis/docs/commands/list/lpushx.mdx */ lpushx = (key: string, ...elements: TData[]) => new LPushXCommand([key, ...elements], this.opts).exec(this.client); /** * @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) => new LRangeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/lrem * @see node_modules/@upstash/redis/docs/commands/list/lrem.mdx */ lrem = (key: string, count: number, value: TData) => new LRemCommand([key, count, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/lset * @see node_modules/@upstash/redis/docs/commands/list/lset.mdx */ lset = (key: string, index: number, value: TData) => new LSetCommand([key, index, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/ltrim * @see node_modules/@upstash/redis/docs/commands/list/ltrim.mdx */ ltrim = (...args: CommandArgs) => new LTrimCommand(args, this.opts).exec(this.client); /** * @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) => new MGetCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/mset * @see node_modules/@upstash/redis/docs/commands/string/mset.mdx */ mset = (kv: Record) => new MSetCommand([kv], this.opts).exec(this.client); /** * @see https://redis.io/commands/msetnx * @see node_modules/@upstash/redis/docs/commands/string/msetnx.mdx */ msetnx = (kv: Record) => new MSetNXCommand([kv], this.opts).exec(this.client); /** * @see https://redis.io/commands/persist * @see node_modules/@upstash/redis/docs/commands/generic/persist.mdx */ persist = (...args: CommandArgs) => new PersistCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/pexpire * @see node_modules/@upstash/redis/docs/commands/generic/pexpire.mdx */ pexpire = (...args: CommandArgs) => new PExpireCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/pexpireat * @see node_modules/@upstash/redis/docs/commands/generic/pexpireat.mdx */ pexpireat = (...args: CommandArgs) => new PExpireAtCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/pfadd */ pfadd = (...args: CommandArgs) => new PfAddCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/pfcount */ pfcount = (...args: CommandArgs) => new PfCountCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/pfmerge */ pfmerge = (...args: CommandArgs) => new PfMergeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/ping * @see node_modules/@upstash/redis/docs/commands/auth/ping.mdx */ ping = (args?: CommandArgs) => new PingCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/psetex */ psetex = (key: string, ttl: number, value: TData) => new PSetEXCommand([key, ttl, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/psubscribe * @see node_modules/@upstash/redis/docs/commands/pubsub/psubscribe.mdx * Messages are JSON-parsed automatically: a published "123" arrives as the number 123. Unlike * subscribe, a message that is not valid JSON (such as "hello") never reaches the listener and * emits an "error" event instead. Pass automaticDeserialization: false to the Redis constructor * to receive raw strings. */ psubscribe = (patterns: string | string[]): Subscriber => { const patternArray = Array.isArray(patterns) ? patterns : [patterns]; return new Subscriber(this.client, patternArray, true, this.opts); }; /** * @see https://redis.io/commands/pttl * @see node_modules/@upstash/redis/docs/commands/generic/pttl.mdx */ pttl = (...args: CommandArgs) => new PTtlCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/publish * @see node_modules/@upstash/redis/docs/commands/pubsub/publish.mdx */ publish = (...args: CommandArgs) => new PublishCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/randomkey * @see node_modules/@upstash/redis/docs/commands/generic/randomkey.mdx */ randomkey = () => new RandomKeyCommand().exec(this.client); /** * @see https://redis.io/commands/rename * @see node_modules/@upstash/redis/docs/commands/generic/rename.mdx */ rename = (...args: CommandArgs) => new RenameCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/renamenx * @see node_modules/@upstash/redis/docs/commands/generic/renamenx.mdx */ renamenx = (...args: CommandArgs) => new RenameNXCommand(args, this.opts).exec(this.client); /** * @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) => new RPopCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/rpush * @see node_modules/@upstash/redis/docs/commands/list/rpush.mdx */ rpush = (key: string, ...elements: TData[]) => new RPushCommand([key, ...elements], this.opts).exec(this.client); /** * @see https://redis.io/commands/rpushx * @see node_modules/@upstash/redis/docs/commands/list/rpushx.mdx */ rpushx = (key: string, ...elements: TData[]) => new RPushXCommand([key, ...elements], this.opts).exec(this.client); /** * @see https://redis.io/commands/sadd * @see node_modules/@upstash/redis/docs/commands/set/sadd.mdx */ sadd = (key: string, member: TData, ...members: TData[]) => new SAddCommand([key, member, ...members], this.opts).exec(this.client); /** * @see https://redis.io/commands/scan * @see node_modules/@upstash/redis/docs/commands/generic/scan.mdx */ scan(cursor: string | number): Promise; scan( cursor: string | number, opts: TOptions ): Promise; scan( cursor: string | number, opts?: TOptions ): Promise { return new ScanCommand([cursor, opts], this.opts).exec(this.client); } /** * @see https://redis.io/commands/scard * @see node_modules/@upstash/redis/docs/commands/set/scard.mdx */ scard = (...args: CommandArgs) => new SCardCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/script-exists * @see node_modules/@upstash/redis/docs/commands/scripts/script_exists.mdx */ scriptExists = (...args: CommandArgs) => new ScriptExistsCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/script-flush * @see node_modules/@upstash/redis/docs/commands/scripts/script_flush.mdx */ scriptFlush = (...args: CommandArgs) => new ScriptFlushCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/script-load * @see node_modules/@upstash/redis/docs/commands/scripts/script_load.mdx */ scriptLoad = (...args: CommandArgs) => new ScriptLoadCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sdiff * @see node_modules/@upstash/redis/docs/commands/set/sdiff.mdx */ sdiff = (...args: CommandArgs) => new SDiffCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sdiffstore * @see node_modules/@upstash/redis/docs/commands/set/sdiffstore.mdx */ sdiffstore = (...args: CommandArgs) => new SDiffStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/set * @see node_modules/@upstash/redis/docs/commands/string/set.mdx */ set = (key: string, value: TData, opts?: SetCommandOptions) => new SetCommand([key, value, opts], this.opts).exec(this.client); /** * @see https://redis.io/commands/setbit * @see node_modules/@upstash/redis/docs/commands/bitmap/setbit.mdx */ setbit = (...args: CommandArgs) => new SetBitCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/setex */ setex = (key: string, ttl: number, value: TData) => new SetExCommand([key, ttl, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/setnx */ setnx = (key: string, value: TData) => new SetNxCommand([key, value], this.opts).exec(this.client); /** * @see https://redis.io/commands/setrange * @see node_modules/@upstash/redis/docs/commands/string/setrange.mdx */ setrange = (...args: CommandArgs) => new SetRangeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sinter * @see node_modules/@upstash/redis/docs/commands/set/sinter.mdx */ sinter = (...args: CommandArgs) => new SInterCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sintercard */ sintercard = (...args: CommandArgs) => new SInterCardCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sinterstore * @see node_modules/@upstash/redis/docs/commands/set/sinterstore.mdx */ sinterstore = (...args: CommandArgs) => new SInterStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sismember * @see node_modules/@upstash/redis/docs/commands/set/sismember.mdx */ sismember = (key: string, member: TData) => new SIsMemberCommand([key, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/smismember * @see node_modules/@upstash/redis/docs/commands/set/smismember.mdx */ smismember = (key: string, members: TMembers) => new SMIsMemberCommand([key, members], this.opts).exec(this.client); /** * @see https://redis.io/commands/smembers * @see node_modules/@upstash/redis/docs/commands/set/smembers.mdx */ smembers = (...args: CommandArgs) => new SMembersCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/smove * @see node_modules/@upstash/redis/docs/commands/set/smove.mdx */ smove = (source: string, destination: string, member: TData) => new SMoveCommand([source, destination, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/spop * @see node_modules/@upstash/redis/docs/commands/set/spop.mdx */ spop = (...args: CommandArgs) => new SPopCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/srandmember * @see node_modules/@upstash/redis/docs/commands/set/srandmember.mdx */ srandmember = (...args: CommandArgs) => new SRandMemberCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/srem * @see node_modules/@upstash/redis/docs/commands/set/srem.mdx */ srem = (key: string, ...members: TData[]) => new SRemCommand([key, ...members], this.opts).exec(this.client); /** * @see https://redis.io/commands/sscan * @see node_modules/@upstash/redis/docs/commands/set/sscan.mdx */ sscan = (...args: CommandArgs) => new SScanCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/strlen * @see node_modules/@upstash/redis/docs/commands/string/strlen.mdx */ strlen = (...args: CommandArgs) => new StrLenCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/subscribe * @see node_modules/@upstash/redis/docs/commands/pubsub/subscribe.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. */ subscribe = (channels: string | string[]): Subscriber => { const channelArray = Array.isArray(channels) ? channels : [channels]; return new Subscriber(this.client, channelArray, false, this.opts); }; /** * @see https://redis.io/commands/sunion * @see node_modules/@upstash/redis/docs/commands/set/sunion.mdx */ sunion = (...args: CommandArgs) => new SUnionCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/sunionstore * @see node_modules/@upstash/redis/docs/commands/set/sunionstore.mdx */ sunionstore = (...args: CommandArgs) => new SUnionStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/time */ time = () => new TimeCommand().exec(this.client); /** * @see https://redis.io/commands/touch * @see node_modules/@upstash/redis/docs/commands/generic/touch.mdx */ touch = (...args: CommandArgs) => new TouchCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/ttl * @see node_modules/@upstash/redis/docs/commands/generic/ttl.mdx */ ttl = (...args: CommandArgs) => new TtlCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/type * @see node_modules/@upstash/redis/docs/commands/generic/type.mdx */ type = (...args: CommandArgs) => new TypeCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/unlink * @see node_modules/@upstash/redis/docs/commands/generic/unlink.mdx */ unlink = (...args: CommandArgs) => new UnlinkCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xadd * @see node_modules/@upstash/redis/docs/commands/stream/xadd.mdx */ xadd = (...args: CommandArgs) => new XAddCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xack * @see node_modules/@upstash/redis/docs/commands/stream/xack.mdx */ xack = (...args: CommandArgs) => new XAckCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xackdel * @see node_modules/@upstash/redis/docs/commands/stream/xackdel.mdx */ xackdel = (...args: CommandArgs) => new XAckDelCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xdel * @see node_modules/@upstash/redis/docs/commands/stream/xdel.mdx */ xdel = (...args: CommandArgs) => new XDelCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xdelex * @see node_modules/@upstash/redis/docs/commands/stream/xdelex.mdx */ xdelex = (...args: CommandArgs) => new XDelExCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xgroup * @see node_modules/@upstash/redis/docs/commands/stream/xgroup.mdx */ xgroup = (...args: CommandArgs) => new XGroupCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xread * @see node_modules/@upstash/redis/docs/commands/stream/xread.mdx */ xread = (...args: CommandArgs) => new XReadCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xreadgroup * @see node_modules/@upstash/redis/docs/commands/stream/xreadgroup.mdx */ xreadgroup = (...args: CommandArgs) => new XReadGroupCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xinfo * @see node_modules/@upstash/redis/docs/commands/stream/xinfo.mdx */ xinfo = (...args: CommandArgs) => new XInfoCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xlen * @see node_modules/@upstash/redis/docs/commands/stream/xlen.mdx */ xlen = (...args: CommandArgs) => new XLenCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xpending * @see node_modules/@upstash/redis/docs/commands/stream/xpending.mdx */ xpending = (...args: CommandArgs) => new XPendingCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xclaim * @see node_modules/@upstash/redis/docs/commands/stream/xclaim.mdx */ xclaim = (...args: CommandArgs) => new XClaimCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xautoclaim * @see node_modules/@upstash/redis/docs/commands/stream/xautoclaim.mdx */ xautoclaim = (...args: CommandArgs) => new XAutoClaim(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/xtrim * @see node_modules/@upstash/redis/docs/commands/stream/xtrim.mdx */ xtrim = (...args: CommandArgs) => new XTrimCommand(args, this.opts).exec(this.client); /** * @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) => new XRangeCommand>(args, this.opts).exec(this.client); /** * @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 ) => new XRevRangeCommand>(args, this.opts).exec(this.client); /** * @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 new ZAddCommand([args[0], args[1], ...(args.slice(2) as any)], this.opts).exec( this.client ); } return new ZAddCommand( [args[0], args[1] as any, ...(args.slice(2) as any)], this.opts ).exec(this.client); }; /** * @see https://redis.io/commands/zcard * @see node_modules/@upstash/redis/docs/commands/zset/zcard.mdx */ zcard = (...args: CommandArgs) => new ZCardCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zcount * @see node_modules/@upstash/redis/docs/commands/zset/zcount.mdx */ zcount = (...args: CommandArgs) => new ZCountCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zdiffstore * @see node_modules/@upstash/redis/docs/commands/zset/zdiffstore.mdx */ zdiffstore = (...args: CommandArgs) => new ZDiffStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zincrby * @see node_modules/@upstash/redis/docs/commands/zset/zincrby.mdx */ zincrby = (key: string, increment: number, member: TData) => new ZIncrByCommand([key, increment, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/zinterstore * @see node_modules/@upstash/redis/docs/commands/zset/zinterstore.mdx */ zinterstore = (...args: CommandArgs) => new ZInterStoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zlexcount * @see node_modules/@upstash/redis/docs/commands/zset/zlexcount.mdx */ zlexcount = (...args: CommandArgs) => new ZLexCountCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zmscore * @see node_modules/@upstash/redis/docs/commands/zset/zmscore.mdx */ zmscore = (...args: CommandArgs) => new ZMScoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zpopmax * @see node_modules/@upstash/redis/docs/commands/zset/zpopmax.mdx */ zpopmax = (...args: CommandArgs) => new ZPopMaxCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zpopmin * @see node_modules/@upstash/redis/docs/commands/zset/zpopmin.mdx */ zpopmin = (...args: CommandArgs) => new ZPopMinCommand(args, this.opts).exec(this.client); /** * @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, ] ) => new ZRangeCommand(args as any, this.opts).exec(this.client); /** * @see https://redis.io/commands/zrank * @see node_modules/@upstash/redis/docs/commands/zset/zrank.mdx */ zrank = (key: string, member: TData) => new ZRankCommand([key, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/zrem * @see node_modules/@upstash/redis/docs/commands/zset/zrem.mdx */ zrem = (key: string, ...members: TData[]) => new ZRemCommand([key, ...members], this.opts).exec(this.client); /** * @see https://redis.io/commands/zremrangebylex * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebylex.mdx */ zremrangebylex = (...args: CommandArgs) => new ZRemRangeByLexCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zremrangebyrank * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebyrank.mdx */ zremrangebyrank = (...args: CommandArgs) => new ZRemRangeByRankCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zremrangebyscore * @see node_modules/@upstash/redis/docs/commands/zset/zremrangebyscore.mdx */ zremrangebyscore = (...args: CommandArgs) => new ZRemRangeByScoreCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zrevrank * @see node_modules/@upstash/redis/docs/commands/zset/zrevrank.mdx */ zrevrank = (key: string, member: TData) => new ZRevRankCommand([key, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/zscan * @see node_modules/@upstash/redis/docs/commands/zset/zscan.mdx */ zscan = (...args: CommandArgs) => new ZScanCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zscore * @see node_modules/@upstash/redis/docs/commands/zset/zscore.mdx */ zscore = (key: string, member: TData) => new ZScoreCommand([key, member], this.opts).exec(this.client); /** * @see https://redis.io/commands/zunion */ zunion = (...args: CommandArgs) => new ZUnionCommand(args, this.opts).exec(this.client); /** * @see https://redis.io/commands/zunionstore * @see node_modules/@upstash/redis/docs/commands/zset/zunionstore.mdx */ zunionstore = (...args: CommandArgs) => new ZUnionStoreCommand(args, this.opts).exec(this.client); }