Redis
Redis clients send Redis 7.2.4 standalone commands to the pgredis gateway. The gateway runs each command in
the pg_redis extension, which keeps every key in ordinary PostgreSQL tables. The same commands are callable from
SQL, so a Redis write can commit or roll back together with business rows.
How Redis maps onto PostgreSQL
- Data types are WAL-logged tables:
redis._keyspaceholds the binary key, type, value and expiry;_hash,_list,_set,_zsetand the_stream*tables hold the rest. - Each command is one PostgreSQL transaction. The reply leaves only after commit.
EXECruns the whole queue in one transaction. A reply whose outcome is unknown is never replayed. - SQL:
redis.command(text[], db)andredis.command_bin(bytea[], db)call the same core and join the caller’s transaction (READ COMMITTEDonly). - Pub/Sub and blocking commands use tables plus
NOTIFYwake-ups and leases. - Write commands other than plain
GET/SETrun one at a time per database; WAL flush latency limits their throughput.
Try it
Out of scope
Lua scripting, Functions, Cluster, Sentinel, Redis replication, AOF/RDB files, maxmemory eviction and modules.
Redis ACL mode is Beta and incomplete. The extension needs superuser and preload, so it does not install on
managed PostgreSQL services.
Source and credit
pgredis is developed by PGSTY and pgredis contributors. Redis is a trademark of Redis Ltd.; Mimus is not affiliated with Redis Ltd.
Pages in this section adapt the pgredis companion documentation, © PGSTY and pgredis contributors, CC BY 4.0; see Licence and attribution.
Install pgredis 0.1.0, configure PostgreSQL, start the gateway and run PING, SET and GET.
Connect clients, roll back Redis writes with SQL, store binary data and build a transactional outbox.
Committed and Beta features, unsupported Redis features, differences and test results.
Gateway, extension and storage: how one semantic core serves RESP and SQL.
Commands, data types, SQL API, transactions, Pub/Sub, Streams, configuration and limits.
Install, build, secure, upgrade, back up and recover pgredis.
Current candidate, what has been verified on it, known issues and the remaining roadmap.
The release candidate and the development checkpoints that led to it.
Design decisions behind pgredis.