npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vortexdd/effect-redis-bun

v2.0.0

Published

Effect Redis service and KeyValueStore integration using Bun's native Redis client

Readme

@vortexdd/effect-redis-bun

Effect-first Redis integration for Bun.

The library exposes two layers of abstraction:

  • Redis: an Effect service with Redis operations wrapped in Effect
  • KeyValueStore: a higher-level store built on top of that service

This package is intentionally scoped to Bun's native Redis client.

Requirements

  • Bun >= 1.2.22
  • Redis Server >= 7.2 or Valkey
  • Effect >= 3.1.2
  • @effect/platform >= 0.52.3

Installation

bun add @vortexdd/effect-redis-bun

What It Exposes

Redis

The Redis service exposes Effect-wrapped operations for the minimum low-level surface:

  • connect
  • close
  • send
  • get
  • getBuffer
  • set
  • del
  • scan

KeyValueStore

The KeyValueStore adapter is built from the Redis service and supports:

  • get
  • getUint8Array
  • set
  • remove
  • clear
  • size

Usage

KeyValueStore Layer

import { KeyValueStore } from "@effect/platform";
import { Effect } from "effect";
import { makeLayer } from "@vortexdd/effect-redis-bun";

const RedisStoreLive = makeLayer({
  host: "localhost",
  port: 6379,
  database: 0,
  scanBatchSize: 200,
});

const program = Effect.gen(function* () {
  const store = yield* KeyValueStore.KeyValueStore;

  yield* store.set("user:123", JSON.stringify({ name: "Alice" }));
  const value = yield* store.get("user:123");
  yield* store.remove("user:123");

  return value;
});

await Effect.runPromise(program.pipe(Effect.provide(RedisStoreLive)));

Redis Service Layer

import { Effect } from "effect";
import { makeRedisLayer, Redis } from "@vortexdd/effect-redis-bun";

const RedisLive = makeRedisLayer({
  host: "localhost",
  port: 6379,
});

const program = Effect.gen(function* () {
  const redis = yield* Redis;

  yield* redis.connect;
  yield* redis.set("raw:key", "value");
  const value = yield* redis.get("raw:key");
  const scan = yield* redis.scan("0", "MATCH", "raw:*", "COUNT", 50);
  yield* redis.del("raw:key");
  yield* redis.close;

  return { value, scan };
});

await Effect.runPromise(program.pipe(Effect.provide(RedisLive)));

Build from an Existing Bun Client

import { RedisClient } from "bun";
import { fromClient, fromClientService } from "@vortexdd/effect-redis-bun";

const client = new RedisClient("redis://localhost:6379/0", {
  enableOfflineQueue: false,
});

const redis = fromClientService(client);
const store = fromClient(client, {
  scanBatchSize: 100,
});

Build a KeyValueStore from an Existing Redis Service

import { KeyValueStore } from "@effect/platform";
import { Effect, Layer } from "effect";
import {
  fromClientService,
  layerFromRedis,
  Redis,
} from "@vortexdd/effect-redis-bun";

const program = Effect.gen(function* () {
  const store = yield* KeyValueStore.KeyValueStore;
  yield* store.set("cache:key", "value");
  return yield* store.get("cache:key");
}).pipe(
  Effect.provide(
    Layer.provide(
      layerFromRedis({ scanBatchSize: 50 }),
      Layer.succeed(Redis, fromClientService(client))
    )
  )
);

API

Redis

Effect service tag for the low-level Redis API.

buildUrl(config: ConnectionConfig)

Builds a Redis URL from ConnectionConfig.

createClient(config: ConnectionConfig)

Creates a Bun RedisClient instance.

fromClientService(client: RedisClient)

Builds a Redis service from an existing Bun client.

fromService(redis: RedisService, options?)

Builds a KeyValueStore from an existing Redis service.

fromClient(client: RedisClient, options?)

Builds a KeyValueStore directly from a Bun client.

makeRedisLayer(config: ConnectionConfig)

Creates a scoped layer that provides Redis.

layerFromRedis(options?)

Creates a KeyValueStore layer from an already-provided Redis service.

makeKeyValueStoreLayer(config: ConnectionConfig)

Creates a scoped layer that provides KeyValueStore.

makeLayer(config: ConnectionConfig)

Alias of makeKeyValueStoreLayer(config).

ConnectionConfig

interface ConnectionConfig {
  readonly host: string;
  readonly port: number;
  readonly username?: string;
  readonly password?: string;
  readonly database?: number;
  readonly tls?: boolean;
  readonly connectTimeoutMs?: number;
  readonly scanBatchSize?: number;
}

Notes

  • makeRedisLayer creates a ready-to-use service and closes the client when the layer scope ends.
  • clear uses SCAN in batches and avoids KEYS *.
  • size uses DBSIZE instead of scanning the full keyspace.
  • scan falls back to send("SCAN", ...) if the Bun client version does not expose scan directly.

Breaking Change From 1.x

Version 2.x removes the public service that exposed the raw Bun client directly.

If you were using the old raw-client layer, migrate to one of these:

  • makeRedisLayer(config) if you want low-level Redis commands as Effect
  • makeLayer(config) or makeKeyValueStoreLayer(config) if you want KeyValueStore
  • fromClientService(client) if you already own the Bun client instance