Coconstructor
Bun

constructor

RedisClient.constructor

constructor RedisClient(
url?: string,
options?: RedisOptions

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 valkey = new RedisClient();

await valkey.set("hello", "world");

console.log(await valkey.get("hello"));

Referenced types

interface RedisOptions

  • autoReconnect?: boolean

    Whether to automatically reconnect

  • connectionTimeout?: number

    Connection timeout in milliseconds

  • enableAutoPipelining?: boolean

    Whether to enable auto-pipelining

  • enableOfflineQueue?: boolean

    Whether to queue commands when disconnected

  • idleTimeout?: number

    Idle timeout in milliseconds

  • maxRetries?: number

    Maximum number of reconnection attempts

  • tls?: boolean | { ca: string | Buffer<ArrayBufferLike> | string | Buffer<ArrayBufferLike>[]; cert: string | Buffer<ArrayBufferLike>; key: string | Buffer<ArrayBufferLike>; rejectUnauthorized: boolean }

    TLS options Can be a boolean or an object with TLS options

namespace RedisClient