Mhrandfield
Bun

method

RedisClient.hrandfield

key: KeyLike
): Promise<null | string>;

Get one or multiple random fields from a hash

@param key

The hash key

@returns

Promise that resolves with a random field name, or null if the hash doesn't exist

key: KeyLike,
count: number
): Promise<string[]>;

Get one or multiple random fields from a hash

@param key

The hash key

@param count

The number of fields to return (positive for unique fields, negative for potentially duplicate fields)

@returns

Promise that resolves with an array of random field names

key: KeyLike,
count: number,
withValues: 'WITHVALUES'
): Promise<[string, string][]>;

Get one or multiple random fields with values from a hash

@param key

The hash key

@param count

The number of fields to return

@param withValues

Literal "WITHVALUES" to include values

@returns

Promise that resolves with an array of alternating field names and values

Referenced types

type KeyLike = string | ArrayBufferView | Blob