Mset
Bun

method

RedisClient.set

key: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>
): 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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
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: string | Blob | ArrayBufferView<ArrayBufferLike>,
value: string | Blob | ArrayBufferView<ArrayBufferLike>,
...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

class Blob

A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.

MDN Reference

  • readonly size: number
  • readonly type: string
  • Returns a promise that resolves to the contents of the blob as an ArrayBuffer

  • bytes(): Promise<Uint8Array<ArrayBufferLike>>;

    Returns a promise that resolves to the contents of the blob as a Uint8Array (array of bytes) its the same as new Uint8Array(await blob.arrayBuffer())

  • formData(): Promise<FormData>;

    Read the data from the blob as a FormData object.

    This first decodes the data from UTF-8, then parses it as a multipart/form-data body or a application/x-www-form-urlencoded body.

    The type property of the blob is used to determine the format of the body.

    This is a non-standard addition to the Blob API, to make it conform more closely to the BodyMixin API.

  • json(): Promise<any>;

    Read the data from the blob as a JSON object.

    This first decodes the data from UTF-8, then parses it as JSON.

  • start?: number,
    end?: number,
    contentType?: string
    ): Blob;
  • stream(): ReadableStream<Uint8Array<ArrayBufferLike>>;

    Returns a readable stream of the blob's contents

  • text(): Promise<string>;

    Returns a promise that resolves to the contents of the blob as a string

type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> = NodeJS.TypedArray<TArrayBuffer> | DataView<TArrayBuffer>