Bun
Connect to Redis from Bun over TCP, TLS or a Unix socket with RedisBun.
RedisBun has the same constructors and options as RedisNode, but opens its sockets with Bun.connect. Import it from @effect-kit/redis/bun.
Example (Creating the Bun Layer)
import { } from "effect";
import { } from "@effect-kit/redis";
import { } from "@effect-kit/redis/bun";
const = .({ : "redis://localhost:6379" });
const = .(function* () {
const = yield* ;
return yield* .();
});
export const = .(.());Creating the layer
| Constructor | Builds a layer for |
|---|---|
RedisBun.layer, RedisBun.layerConfig | One standalone server |
RedisBun.layerCluster, RedisBun.layerClusterConfig | A cluster |
RedisBun.layerSentinel, RedisBun.layerSentinelConfig | A Sentinel deployment |
The layer export is the transport
layer exported from @effect-kit/redis/bun is the transport, not a client. Build clients with
RedisBun.layer(...).
Provided services
RedisBun.layer provides the same services as RedisNode.layer.
Example (The Services a Bun Layer Provides)
import type { } from "effect";
import { } from "@effect-kit/redis/bun";
const = .({ : "redis://localhost:6379" });
type Provided = .<typeof >;Transport options
The transport uses Bun.connect for TCP, TLS and Unix sockets. The url, endpoint and tls shapes are the ones in Node.js, including serverName, ca, certificate, privateKey and rejectUnauthorized.
Example (Connecting Over a Unix Socket)
import { } from "@effect-kit/redis/bun";
export const = .({ : { : "/var/run/redis/redis.sock" } });Cluster and Sentinel need TCP endpoints, as on Node.js.
Tested version
The package is tested on Bun 1.4.4, against Redis and Valkey, including Cluster, Sentinel and a Unix socket. The Unix socket test runs on Linux.