Skip to content
PostgreSQL 15 & 16 Rust + pgrx 0.11 RESP2 & RESP3 Pub/Sub (Named & Pattern) Sandboxed Lua 5.1 AUTH & Universal TTL BullMQ 5.13 Ready

pg_redis_core

Speak native Redis (RESP2 & RESP3) on port 6379 directly inside PostgreSQL 15 & 16. Keep your existing ioredis, BullMQ, redis-py, Jedis, and go-redis/v9 drivers while unifying cache, queues, Pub/Sub, and relational persistence inside a single ACID-compliant database.

504K req/s
Hot-key L1-cached GET (p50 = 0.27ms)
8.5K req/s
Pipelined SET throughput (UNLOGGED)
RESP2 & 3
Zero-copy redis-protocol 6.0 parser
1 Database
Zero cache-invalidation drift or dual ops

Why pg_redis_core?

  • Break Free from RAM-Bound Costs


    Store gigabytes of sessions, queues, leaderboards, and cached payloads on SSD/NVMe-backed PostgreSQL tables instead of expensive memory-only clusters.

  • Single ACID Source of Truth


    Query, join, audit, and back up your Redis keys directly using standard PostgreSQL SQL across all seven catalog tables (pg_redis_strings, pg_redis_hashes, pg_redis_lists, pg_redis_zsets, pg_redis_sets, pg_redis_streams, pg_redis_key_expiry) with universal TTL support.

  • Engineered for Speed


    Combines an in-process moka L1 hot-key cache, SPI_keepplan prepared statements, pipelined transaction batching, fillfactor = 80 HOT updates, and optional UNLOGGED WAL bypass.

  • Drop-In Driver & BullMQ Compatibility


    Verified against unmodified BullMQ 5.13.0 (Medusa queues: sandboxed Lua 5.1 + cmsgpack + cjson + XADD + BZPOPMIN + HSCAN/SSCAN/ZSCAN + CLIENT LIST), ioredis@5.11.1, redis-py / FastAPI, Jedis (Kotlin), go-redis/v9 (RESP3), and redis-cli.

  • In-Process Named & Pattern Pub/Sub


    Zero-SPI-overhead PUBLISH, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, and PUBSUB (CHANNELS/NUMSUB/NUMPAT) supporting binary-safe payloads far beyond PostgreSQL's 8 KB NOTIFY limit with bounded slow-consumer queues.

  • Production Security & Resource Limits


    Constant-time AUTH & HELLO ... AUTH (pg_redis.requirepass), sandboxed Lua 5.1 VM with configurable execution timeout (pg_redis.lua_time_limit_ms), connection caps (pg_redis.max_clients), and frame memory bounds (pg_redis.max_frame_bytes).

30-Second Preview

git clone https://github.com/MegacoderKim/pg2redis.git
cd pg2redis

# Boot PostgreSQL 15 with pg_redis_core listening on :5432 and :6379
# (or pull prebuilt ghcr.io/megacoderkim/pg2redis:latest-pg16)
docker compose up -d --build --wait pg-redis

# Write via Redis protocol
docker compose exec pg-redis redis-cli SET greeting "hello from postgres"

# Read directly from PostgreSQL SQL
docker compose exec pg-redis psql -U postgres -c \
  "SELECT key, convert_from(value, 'UTF8') AS value FROM pg_redis_strings;"
flowchart LR
    C1["Python<br/>redis-py / FastAPI"] -->|RESP2 :6379| BG
    C2["Node.js<br/>ioredis / BullMQ"] -->|RESP2 :6379| BG
    C3["Kotlin / Go<br/>Jedis · go-redis/v9"] -->|RESP2/3 :6379| BG

    subgraph PG["PostgreSQL 15 & 16 Process"]
        BG["pg_redis_core BGWorker<br/>Tokio current_thread + AUTH/Limits"]
        L1["L1 Hot-Key Cache<br/>(moka)"]
        PS["PubSubHub &amp; KeyNotifier<br/>(Named/Pattern + Blocking)"]
        LUA["Sandboxed Lua 5.1<br/>(mlua + Timeout)"]
        SPI["Prepared SPI Plans<br/>(SPI_keepplan)"]
        TBL[("Relational Catalog<br/>strings · hashes · lists · zsets<br/>sets · streams · key_expiry")]

        BG -->|Hot GET| L1
        BG -->|Pub/Sub &amp; Block| PS
        BG -->|EVAL/EVALSHA| LUA
        LUA --> SPI
        BG -->|Batched Tx| SPI
        SPI --> TBL
    end