Storage
All durable Redis state lives in ordinary WAL-logged PostgreSQL tables inside schema redis. The Go gateway holds no persistent data of its own.
Keyspace and binary identity
Every Redis key has one row in redis._keyspace:
- Digest-indexed lookup: Unbounded binary keys (
bytea, up to 512 MiB) never enter a PostgreSQL B-tree index directly. Instead,pg_redisindexes(db, digest)using a 32-byte SHA-256 digest, locks the digest bucket, and compares the fullkeybytes to resolve hash collisions safely. - Collection child rows: Hash fields (
redis._hash), Set members (redis._set), ZSet members (redis._zset), Stream groups (redis._stream_group) and Stream consumers (redis._stream_consumer) use the same 32-bytedigest+ fullbyteacomparison rule, referencingredis._keyspace(id)withON DELETE CASCADE. - Sorted sets:
redis._zsetstoresscore double precision(rejectingNaN) and breaks ties by comparing full member bytes. - Lists and length cache:
redis._listorders elements by(kid, pos, id)without putting elementvaluebytes in a B-tree. Schema0.54addsredis._list_length(kid, length), maintained by statement-level transition-table triggers onredis._listsoLLEN,LPUSHandRPUSHread one row instead of counting every element.
Table inventory (schema 0.54)
| Category | Tables | Purpose |
|---|---|---|
| Keyspace and Strings | redis._keyspace | Logical DB (0–15), 32-byte digest, binary key, type tag (s, h, l, S, z, x), inline payload (value for Strings, Bitmaps, HLL) and millisecond deadline (expires) |
| Hashes | redis._hash | (kid, digest, field, value) rows per hash field |
| Lists | redis._list, redis._list_length | (kid, pos, value) element rows and statement-trigger-maintained per-list length cache |
| Sets | redis._set | (kid, digest, member) rows per set member |
| Sorted sets ( and Geo) | redis._zset | (kid, digest, member, score) rows; Geo keys store 52-bit geohash integers as ZSet scores |
| Streams | redis._stream, redis._stream_entry, redis._stream_node, redis._stream_radix, redis._stream_group, redis._stream_consumer, redis._stream_pel, redis._stream_config | Stream metadata (last_id, max_deleted_id, entries_added), live entries, listpack nodes, radix tree prefixes, consumer groups, consumers and Pending Entries List (PEL) |
| Object metadata | redis._object_encoding, redis._object_heat, redis._object_shared_heat, redis._object_reference, redis._object_config | Encoding state, optional listpack/quicklist layout (pg_redis.list_layout_tracking), optional LRU/LFU heat (pg_redis.object_heat_tracking) and shared-integer tracking |
| Transactions | redis._transaction_session, redis._watch, redis._exec_context, redis._mutation_stats | WATCH key versions, EXEC context and per-key mutation counters |
| Blocking commands | redis._blocked, redis._block_keys, redis._ready | Blocked waiter registrations, watched keys per waiter and committed handoff replies |
| Pub/Sub | redis._pubsub_session, redis._pubsub_subscription, redis._pubsub_message, redis._notify_config | Subscriber sessions, channel/pattern/shard bindings, message ring pages and keyspace-event configuration |
| Client tracking | redis._tracking_client, redis._tracking_key, redis._tracking_prefix, redis._tracking_pending, redis._tracking_config | Client-side caching sessions, tracked key digests, BCAST prefixes and queued invalidations |
| Auth and Redis ACL | redis._acl_user, redis._acl_session, redis._acl_log, redis._acl_config, redis._acl_service, redis._auth_ticket, redis._auth_key_ticket | Redis ACL users, rules, security log and session tickets |
| Diagnostics and control | redis._monitor_client, redis._client_pause_control, redis._debug_control, redis._output_config, redis._slowlog_config, redis._encoding_config, redis._hll_config, redis._runtime_identity | MONITOR observers, CLIENT PAUSE deadlines, DEBUG PAUSE-CRON / SET-ACTIVE-EXPIRE state, output buffer limits, SLOWLOG settings and installation identity |
Encoding history and Streams
redis._object_encoding stores per-key encoding metadata (int, embstr, raw, listpack, hashtable, intset, skiplist, stream), and COPY copies this representation state alongside the key. Deleting a key cascades to its child rows and encoding metadata; transaction and savepoint rollback restore both business values and encoding state.
Streams persist both live entries (redis._stream_entry) and physical listpack/radix structures (redis._stream_node, redis._stream_radix) so XTRIM approximate trimming and XINFO STREAM FULL reflect the recorded structure.
Runtime statistics versus durable rows
Keyspace modifications and dirty counters participate in PostgreSQL WAL transactions. Runtime command call counters (INFO commandstats, INFO stats) live in bounded shared memory partitioned by database OID and extension installation identity:
- Rolling back a SQL transaction undoes all table writes and queued notifications, while the in-memory call counter records that the command handler ran.
- Blocking command completion counters update only after the transaction that fixes the blocking result commits; repeated
blocking_pollcalls do not increment completion counts again.
