Mset
Bun

method

RedisClient.set

key: KeyLike,
value: KeyLike
): Promise<'OK'>;

Set key to hold the string value

@param key

The key to set

@param value

The value to set

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
ex: 'EX',
seconds: number
): Promise<'OK'>;

Set key to hold the string value with expiration

@param key

The key to set

@param value

The value to set

@param ex

Set the specified expire time, in seconds

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
px: 'PX',
milliseconds: number
): Promise<'OK'>;

Set key to hold the string value with expiration

@param key

The key to set

@param value

The value to set

@param px

Set the specified expire time, in milliseconds

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
exat: 'EXAT',
timestampSeconds: number
): Promise<'OK'>;

Set key to hold the string value with expiration at a specific Unix timestamp

@param key

The key to set

@param value

The value to set

@param exat

Set the specified Unix time at which the key will expire, in seconds

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
pxat: 'PXAT',
timestampMilliseconds: number
): Promise<'OK'>;

Set key to hold the string value with expiration at a specific Unix timestamp

@param key

The key to set

@param value

The value to set

@param pxat

Set the specified Unix time at which the key will expire, in milliseconds

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
nx: 'NX'
): Promise<null | 'OK'>;

Set key to hold the string value only if key does not exist

@param key

The key to set

@param value

The value to set

@param nx

Only set the key if it does not already exist

@returns

Promise that resolves with "OK" on success, or null if the key already exists

key: KeyLike,
value: KeyLike,
xx: 'XX'
): Promise<null | 'OK'>;

Set key to hold the string value only if key already exists

@param key

The key to set

@param value

The value to set

@param xx

Only set the key if it already exists

@returns

Promise that resolves with "OK" on success, or null if the key does not exist

key: KeyLike,
value: KeyLike,
get: 'GET'
): Promise<null | string>;

Set key to hold the string value and return the old value

@param key

The key to set

@param value

The value to set

@param get

Return the old string stored at key, or null if key did not exist

@returns

Promise that resolves with the old value, or null if key did not exist

key: KeyLike,
value: KeyLike,
keepttl: 'KEEPTTL'
): Promise<'OK'>;

Set key to hold the string value and retain the time to live

@param key

The key to set

@param value

The value to set

@param keepttl

Retain the time to live associated with the key

@returns

Promise that resolves with "OK" on success

key: KeyLike,
value: KeyLike,
...options: string[]
): Promise<null | string>;

Set key to hold the string value with various options

@param key

The key to set

@param value

The value to set

@param options

Array of options (EX, PX, EXAT, PXAT, NX, XX, KEEPTTL, GET)

@returns

Promise that resolves with "OK" on success, null if NX/XX condition not met, or the old value if GET is specified

Referenced types

type KeyLike = string | ArrayBufferView | Blob