constructor
RedisClient.constructor
constructor RedisClient(
url?: string,
Creates a new Redis client
@param url
URL to connect to, defaults to process.env.VALKEY_URL, process.env.REDIS_URL, or "valkey://localhost:6379"
@param options
Additional options
const redis = new RedisClient();
await redis.set("hello", "world");
console.log(await redis.get("hello"));Referenced types
interface RedisOptions
- idleTimeout?: number
Idle timeout in milliseconds. Bun counts it from the last data the server sent. Sending does not reset it. When it fires, Bun closes the connection and runs
onclose. Bun does not reconnect on its own, even withautoReconnect: true. Callconnect()to reconnect. - maxRetries?: number
Maximum number of reconnection attempts before the client gives up and runs
onclose.
namespace RedisClient
- type KeyLike = string | ArrayBufferView | Blob
- type StringPubSubListener = (message: string, channel: string) => void