bun-redis

Implement Redis caching, pub/sub, and session storage in Bun using ioredis or Upstash.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-redis-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bun-redis
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/bun-redis
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill bun-redis-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ioredis, @upstash/redis, redis, hono, uuid, and includes references (resource) components.

What problem does it solve? Working with Redis in a Bun runtime involves choosing the right client, structuring data correctly, and applying proven patterns for caching, sessions, and rate limiting. This Skill provides ready-to-use TypeScript patterns so you avoid connection misconfigurations, wrong data-type errors, and ad-hoc cache logic. ## Core Features & Use Cases - Client Setup: Configure ioredis for self-hosted Redis (including TLS and connection strings) or @upstash/redis for serverless/edge deployments. - Data Structures & Operations: Covers strings, hashes, lists, sets, sorted sets, RedisJSON, pub/sub messaging, transactions, and pipelines. - Application Patterns: Includes cache-aside, write-through caching, rate limiting with INCR/EXPIRE, and Hono-based session storage middleware. - Use Case: You are building a Bun API with Hono and need to cache database queries, throttle requests per user, and persist login sessions. This Skill gives you the exact Redis commands and patterns to implement all three. ## Quick Start Ask the assistant to set up an ioredis client in Bun with a cache-aside pattern for user lookups and a 60-second rate limiter.

Frequently Asked Questions about bun-redis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect to Redis in Bun with ioredis?

Install ioredis with bun add ioredis, then create a client with new Redis() for defaults, an options object with host, port, password, and db, or a connection string like redis://:password@localhost:6379/0. TLS is enabled by passing a tls option.

ioredis vs @upstash/redis: which Redis client for Bun?

Use ioredis for self-hosted Redis servers with full command support including blocking operations and pub/sub. Use @upstash/redis for serverless or edge deployments where connections are short-lived and accessed over a REST API with a URL and token.

How do I implement rate limiting with Redis?

Use INCR on a key and set EXPIRE on the first increment to create a fixed-window counter. If the count exceeds your limit within the window, reject the request. The pattern requires only two Redis commands per check.

Does ioredis support Redis pub/sub in Bun?

Yes, ioredis supports pub/sub by creating separate subscriber and publisher connections. The subscriber uses subscribe() and listens for message events, while the publisher calls publish(). Pattern subscriptions use psubscribe().

Why am I getting ECONNREFUSED or NOAUTH errors with Redis?

ECONNREFUSED means the Redis server is not running or unreachable at the configured host and port. NOAUTH means the server requires a password that was not provided in the client options or connection string.

When should I use Redis pipelines instead of transactions?

Use multi()/exec() transactions when commands must execute atomically as a unit. Use pipelines when you only need to batch commands for fewer round trips and better performance, since pipelines provide no atomicity guarantees.