Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/upstash_redis/pkg/redis.ts>Redis

HTTP based Redis Client for Serverless and Edge Functions
Go to Latest
class Redis
import { Redis } from "https://deno.land/x/upstash_redis@v1.23.4/pkg/redis.ts";

Serverless redis client for upstash.

Constructors

new
Redis(client: Requester, opts?: RedisOptions)

Create a new redis client

Properties

protected
addTelemetry: (telemetry: Telemetry) => unknown

Technically this is not private, we can hide it from intellisense by doing this

protected
client: Requester
protected
enableTelemetry: boolean
protected
optional
opts: CommandOptions<any, any>
append: (...args: CommandArgs<AppendCommand>) => unknown
bitcount: (...args: CommandArgs<BitCountCommand>) => unknown
bitop: { (
op: "and" | "or" | "xor",
destinationKey: string,
sourceKey: string,
...sourceKeys: string[],
): Promise<number>; (
op: "not",
destinationKey: string,
sourceKey: string,
): Promise<number>; }
bitpos: (...args: CommandArgs<BitPosCommand>) => unknown
dbsize: () => unknown
decr: (...args: CommandArgs<DecrCommand>) => unknown
decrby: (...args: CommandArgs<DecrByCommand>) => unknown
del: (...args: CommandArgs<DelCommand>) => unknown
echo: (...args: CommandArgs<EchoCommand>) => unknown
eval: <TArgs extends unknown[], TData = unknown>(...args: [string, string[], TArgs]) => unknown
evalsha: <TArgs extends unknown[], TData = unknown>(...args: [string, string[], TArgs]) => unknown
exists: (...args: CommandArgs<ExistsCommand>) => unknown
expire: (...args: CommandArgs<ExpireCommand>) => unknown
expireat: (...args: CommandArgs<ExpireAtCommand>) => unknown
flushall: (args?: CommandArgs<FlushAllCommand>) => unknown
flushdb: (...args: CommandArgs<FlushDBCommand>) => unknown
get: <TData>(...args: CommandArgs<GetCommand>) => unknown
getbit: (...args: CommandArgs<GetBitCommand>) => unknown
getdel: <TData>(...args: CommandArgs<GetDelCommand>) => unknown
getrange: (...args: CommandArgs<GetRangeCommand>) => unknown
getset: <TData>(key: string, value: TData) => unknown
hdel: (...args: CommandArgs<HDelCommand>) => unknown
hexists: (...args: CommandArgs<HExistsCommand>) => unknown
hget: <TData>(...args: CommandArgs<HGetCommand>) => unknown
hgetall: <TData extends Record<string, unknown>>(...args: CommandArgs<HGetAllCommand>) => unknown
hincrby: (...args: CommandArgs<HIncrByCommand>) => unknown
hincrbyfloat: (...args: CommandArgs<HIncrByFloatCommand>) => unknown
hkeys: (...args: CommandArgs<HKeysCommand>) => unknown
hlen: (...args: CommandArgs<HLenCommand>) => unknown
hmget: <TData extends Record<string, unknown>>(...args: CommandArgs<HMGetCommand>) => unknown
hmset: <TData>(key: string, kv: { [field: string]: TData; }) => unknown
hrandfield: { (key: string): Promise<string>; (key: string, count: number): Promise<string[]>; <TData extends Record<string, unknown>>(
key: string,
count: number,
withValues: boolean,
): Promise<Partial<TData>>; }
hscan: (...args: CommandArgs<HScanCommand>) => unknown
hset: <TData>(key: string, kv: { [field: string]: TData; }) => unknown
hsetnx: <TData>(
key: string,
field: string,
value: TData,
) => unknown
hstrlen: (...args: CommandArgs<HStrLenCommand>) => unknown
hvals: (...args: CommandArgs<HValsCommand>) => unknown
incr: (...args: CommandArgs<IncrCommand>) => unknown
incrby: (...args: CommandArgs<IncrByCommand>) => unknown
incrbyfloat: (...args: CommandArgs<IncrByFloatCommand>) => unknown
readonly
json
keys: (...args: CommandArgs<KeysCommand>) => unknown
lindex: (...args: CommandArgs<LIndexCommand>) => unknown
linsert: <TData>(
key: string,
direction: "before" | "after",
pivot: TData,
value: TData,
) => unknown
llen: (...args: CommandArgs<LLenCommand>) => unknown
lmove: <TData = string>(...args: CommandArgs<LMoveCommand>) => unknown
lpop: <TData>(...args: CommandArgs<LPopCommand>) => unknown
lpos: <TData = number>(...args: CommandArgs<LPosCommand>) => unknown
lpush: <TData>(key: string, ...elements: TData[]) => unknown
lpushx: <TData>(key: string, ...elements: TData[]) => unknown
lrange: <TResult = string>(...args: CommandArgs<LRangeCommand>) => unknown
lrem: <TData>(
key: string,
count: number,
value: TData,
) => unknown
lset: <TData>(
key: string,
index: number,
value: TData,
) => unknown
ltrim: (...args: CommandArgs<LTrimCommand>) => unknown
mget: <TData extends unknown[]>(...args: CommandArgs<MGetCommand>) => unknown
mset: <TData>(kv: { [key: string]: TData; }) => unknown
msetnx: <TData>(kv: { [key: string]: TData; }) => unknown
multi: () => unknown

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.

persist: (...args: CommandArgs<PersistCommand>) => unknown
pexpire: (...args: CommandArgs<PExpireCommand>) => unknown
pexpireat: (...args: CommandArgs<PExpireAtCommand>) => unknown
ping: (args?: CommandArgs<PingCommand>) => unknown
pipeline: () => unknown

Create a new pipeline that allows you to send requests in bulk.

psetex: <TData>(
key: string,
ttl: number,
value: TData,
) => unknown
pttl: (...args: CommandArgs<PTtlCommand>) => unknown
publish: (...args: CommandArgs<PublishCommand>) => unknown
randomkey: () => unknown
rename: (...args: CommandArgs<RenameCommand>) => unknown
renamenx: (...args: CommandArgs<RenameNXCommand>) => unknown
rpop: <TData = string>(...args: CommandArgs<RPopCommand>) => unknown
rpush: <TData>(key: string, ...elements: TData[]) => unknown
rpushx: <TData>(key: string, ...elements: TData[]) => unknown
sadd: <TData>(key: string, ...members: TData[]) => unknown
scan: (...args: CommandArgs<ScanCommand>) => unknown
scard: (...args: CommandArgs<SCardCommand>) => unknown
scriptExists: (...args: CommandArgs<ScriptExistsCommand>) => unknown
scriptFlush: (...args: CommandArgs<ScriptFlushCommand>) => unknown
scriptLoad: (...args: CommandArgs<ScriptLoadCommand>) => unknown
sdiff: (...args: CommandArgs<SDiffCommand>) => unknown
sdiffstore: (...args: CommandArgs<SDiffStoreCommand>) => unknown
set: <TData>(
key: string,
value: TData,
) => unknown
setbit: (...args: CommandArgs<SetBitCommand>) => unknown
setex: <TData>(
key: string,
ttl: number,
value: TData,
) => unknown
setnx: <TData>(key: string, value: TData) => unknown
setrange: (...args: CommandArgs<SetRangeCommand>) => unknown
sinter: (...args: CommandArgs<SInterCommand>) => unknown
sinterstore: (...args: CommandArgs<SInterStoreCommand>) => unknown
sismember: <TData>(key: string, member: TData) => unknown
smembers: <TData extends unknown[] = string[]>(...args: CommandArgs<SMembersCommand>) => unknown
smismember: <TMembers extends unknown[]>(key: string, members: TMembers) => unknown
smove: <TData>(
source: string,
destination: string,
member: TData,
) => unknown
spop: <TData>(...args: CommandArgs<SPopCommand>) => unknown
srandmember: <TData>(...args: CommandArgs<SRandMemberCommand>) => unknown
srem: <TData>(key: string, ...members: TData[]) => unknown
sscan: (...args: CommandArgs<SScanCommand>) => unknown
strlen: (...args: CommandArgs<StrLenCommand>) => unknown
sunion: (...args: CommandArgs<SUnionCommand>) => unknown
sunionstore: (...args: CommandArgs<SUnionStoreCommand>) => unknown
time: () => unknown
touch: (...args: CommandArgs<TouchCommand>) => unknown
ttl: (...args: CommandArgs<TtlCommand>) => unknown
type: (...args: CommandArgs<TypeCommand>) => unknown
use: <TResult = unknown>(middleware: (r: UpstashRequest, next: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>) => Promise<UpstashResponse<TResult>>) => unknown

Wrap a new middleware around the HTTP client.

xadd: (...args: CommandArgs<XAddCommand>) => unknown
xrange: (...args: CommandArgs<XRangeCommand>) => unknown
zadd: <TData>(...args: [string, ScoreMember<TData>, ScoreMember<TData>[]] | [string, ZAddCommandOptions | ZAddCommandOptionsWithIncr, [ScoreMember<TData>, ...ScoreMember<TData>[]]]) => unknown
zcard: (...args: CommandArgs<ZCardCommand>) => unknown
zcount: (...args: CommandArgs<ZCountCommand>) => unknown
zdiffstore: (...args: CommandArgs<ZDiffStoreCommand>) => unknown
zincrby: <TData>(
key: string,
increment: number,
member: TData,
) => unknown
zinterstore: (...args: CommandArgs<ZInterStoreCommand>) => unknown
zlexcount: (...args: CommandArgs<ZLexCountCommand>) => unknown
zmscore: (...args: CommandArgs<ZMScoreCommand>) => unknown
zpopmax: <TData>(...args: CommandArgs<ZPopMaxCommand>) => unknown
zpopmin: <TData>(...args: CommandArgs<ZPopMinCommand>) => unknown
zrange: <TData extends unknown[]>(...args:
[
string,
number,
number,
]
|
[
string,
| `(${string}`
| `[${string}`
| "-"
| "+"
,
| `(${string}`
| `[${string}`
| "-"
| "+"
,
{ byLex: true; } & ZRangeCommandOptions,
]
|
[
string,
| number
| `(${number}`
| "-inf"
| "+inf"
,
| number
| `(${number}`
| "-inf"
| "+inf"
,
{ byScore: true; } & ZRangeCommandOptions,
]
) => unknown
zrank: <TData>(key: string, member: TData) => unknown
zrem: <TData>(key: string, ...members: TData[]) => unknown
zremrangebylex: (...args: CommandArgs<ZRemRangeByLexCommand>) => unknown
zremrangebyrank: (...args: CommandArgs<ZRemRangeByRankCommand>) => unknown
zremrangebyscore: (...args: CommandArgs<ZRemRangeByScoreCommand>) => unknown
zrevrank: <TData>(key: string, member: TData) => unknown
zscan: (...args: CommandArgs<ZScanCommand>) => unknown
zscore: <TData>(key: string, member: TData) => unknown
zunionstore: (...args: CommandArgs<ZUnionStoreCommand>) => unknown

Methods

createScript(script: string): Script