Skip to main content
The ioredis adapter wraps an ioredis client to provide persistent caching with Redis.

Installation

Basic Usage

Configuration

Redis Connection

Adapter Options

With Schema Serialization

Use Effect’s Schema for type-safe serialization:

Key Storage Format

Keys are stored in Redis as:
Examples:

TTL Handling

Redis TTL is set to ttl + swr to ensure stale data is available during the SWR window:

Invalidation

Invalidating a key removes it from both memory and Redis:
invalidateAll only clears the in-memory cache. Redis keys persist until their TTL expires. If you need to clear Redis, use redis.flushdb() or delete keys manually.

Tiered Caching

Combine memory (L1) and Redis (L2) for faster reads:
Behavior:
  1. Check L1 (memory) - fastest
  2. If miss, check L2 (Redis)
  3. On write, update both L1 and L2

Complete Example

Type Signature

Error Handling

Redis errors are converted to Effect failures:
The ioredis adapter converts all Redis operations to Effect and uses Effect.orDie - errors will crash the fiber unless caught with Effect.catchAll or Effect.either.