GET (p50 = 0.27ms)SET throughput (UNLOGGED)redis-protocol 6.0 parserWhy 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
mokaL1 hot-key cache,SPI_keepplanprepared statements, pipelined transaction batching,fillfactor = 80HOT updates, and optionalUNLOGGEDWAL 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), andredis-cli. -
In-Process Named & Pattern Pub/Sub
Zero-SPI-overhead
PUBLISH,SUBSCRIBE,UNSUBSCRIBE,PSUBSCRIBE,PUNSUBSCRIBE, andPUBSUB(CHANNELS/NUMSUB/NUMPAT) supporting binary-safe payloads far beyond PostgreSQL's 8 KBNOTIFYlimit 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 & 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 & Block| PS
BG -->|EVAL/EVALSHA| LUA
LUA --> SPI
BG -->|Batched Tx| SPI
SPI --> TBL
end