<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Architecture on Mimus</title><link>https://mimus.pgsty.com/docs/redis/architecture/</link><description>Recent content in Architecture on Mimus</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 06 Dec 2026 15:37:05 +0800</lastBuildDate><atom:link href="https://mimus.pgsty.com/docs/redis/architecture/index.xml" rel="self" type="application/rss+xml"/><item><title>Session lifecycle</title><link>https://mimus.pgsty.com/docs/redis/architecture/lifecycle/</link><guid>https://mimus.pgsty.com/docs/redis/architecture/lifecycle/</guid><description>&lt;p&gt;While keys and collections persist in PostgreSQL tables across restarts, blocking waits, Pub/Sub subscriptions, client-side caching routes and pooled connections carry session state that requires explicit lifecycle management.&lt;/p&gt;&#10;&lt;h2 id="sessions"&gt;Blocking commands and Pub/Sub&#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Blocking registrations (&lt;code&gt;redis._blocked&lt;/code&gt;, &lt;code&gt;redis._block_keys&lt;/code&gt;, &lt;code&gt;redis._ready&lt;/code&gt;):&lt;/strong&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;When a blocking command (&lt;code&gt;BLPOP&lt;/code&gt;, &lt;code&gt;BLMOVE&lt;/code&gt;, &lt;code&gt;BZPOPMIN&lt;/code&gt;, &lt;code&gt;XREAD BLOCK&lt;/code&gt;, &lt;code&gt;XREADGROUP BLOCK&lt;/code&gt;, &lt;code&gt;WAIT&lt;/code&gt;) cannot be satisfied immediately, &lt;code&gt;redis.blocking_begin&lt;/code&gt; records the waiter, logical database, opaque token, command arguments and reply protocol.&lt;/li&gt;&#10;&lt;li&gt;When a producer writes to a watched key (or when the timeout expires), a single PostgreSQL transaction consumes the element and writes the wire-formatted reply into &lt;code&gt;redis._ready&lt;/code&gt;, then sends a PostgreSQL &lt;code&gt;NOTIFY&lt;/code&gt; wakeup.&lt;/li&gt;&#10;&lt;li&gt;Inside &lt;code&gt;MULTI&lt;/code&gt;/&lt;code&gt;EXEC&lt;/code&gt;, waiters only see the final state after the entire &lt;code&gt;EXEC&lt;/code&gt; batch completes; an item pushed and deleted within the same &lt;code&gt;EXEC&lt;/code&gt; never escapes to a blocked reader.&lt;/li&gt;&#10;&lt;li&gt;The gateway polls &lt;code&gt;redis.blocking_poll&lt;/code&gt; to retrieve the stored reply without re-executing the pop, or calls &lt;code&gt;redis.blocking_cancel&lt;/code&gt; on disconnect.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Pub/Sub and tracking routes (&lt;code&gt;redis._pubsub_*&lt;/code&gt;, &lt;code&gt;redis._tracking_*&lt;/code&gt;):&lt;/strong&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;code&gt;redis.pubsub_open&lt;/code&gt; and &lt;code&gt;redis.pubsub_change&lt;/code&gt; register subscriptions in PostgreSQL tables with a lease deadline.&lt;/li&gt;&#10;&lt;li&gt;Publishers write message pages to &lt;code&gt;redis._pubsub_message&lt;/code&gt; (and tracking invalidations to &lt;code&gt;redis._tracking_pending&lt;/code&gt;) inside their transaction and emit &lt;code&gt;NOTIFY&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;The gateway drains committed batches via &lt;code&gt;redis.pubsub_poll&lt;/code&gt;. Lease expiry garbage-collects abandoned sessions if a gateway crashes, and bounded queue quotas close lagging subscribers when unread bytes exceed limits.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="expiry"&gt;Key expiry and background maintenance&#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Lazy expiry:&lt;/strong&gt; Any foreground command that accesses an expired key removes its physical row inside the current transaction (or treats it as missing on a read-only path).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Active background expiry:&lt;/strong&gt; When &lt;code&gt;pg_redis&lt;/code&gt; is loaded via &lt;code&gt;shared_preload_libraries&lt;/code&gt;, a background coordinator discovers databases containing the extension and runs periodic workers that delete expired rows from &lt;code&gt;redis._keyspace&lt;/code&gt; in batches, clean up expired blocking/Pub/Sub leases, trim tracking tables and compact mutation counters. PostgreSQL &lt;code&gt;VACUUM&lt;/code&gt; later reclaims dead tuples.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Maintenance pause (&lt;code&gt;DEBUG PAUSE-CRON 0|1&lt;/code&gt;):&lt;/strong&gt; Administrators can pause periodic background maintenance in the current database by writing a postmaster-epoch-scoped control row in &lt;code&gt;redis._debug_control&lt;/code&gt;. Workers check this row at the start of each maintenance cycle and skip background cleanup while paused, while foreground commands and lazy expiry continue normally. A PostgreSQL restart starts a new postmaster epoch and automatically resumes default background maintenance.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="connections"&gt;Pooled connection reuse and shutdown&#10;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Each client connection has a single output writer goroutine in the gateway.&lt;/li&gt;&#10;&lt;li&gt;A PostgreSQL backend connection returns to the gateway&amp;rsquo;s per-identity pool only after its business transaction commits and &lt;code&gt;redis._pool_reset()&lt;/code&gt; confirms an idle, clean session (&lt;code&gt;ReadyForQuery = I&lt;/code&gt; and binary &lt;code&gt;true&lt;/code&gt; receipt).&lt;/li&gt;&#10;&lt;li&gt;Connections that encounter an unconfirmed commit, a reset error, a canceled context or an open transaction are closed and discarded from the pool.&lt;/li&gt;&#10;&lt;li&gt;Shutting down or restarting the gateway or PostgreSQL terminates active client connections. Restart recovery restores committed keys and TTL deadlines in PostgreSQL, while clients must reconnect and re-establish &lt;code&gt;WATCH&lt;/code&gt; state, blocking waits and Pub/Sub or tracking subscriptions.&lt;/li&gt;&#10;&lt;/ul&gt;</description></item><item><title>Storage</title><link>https://mimus.pgsty.com/docs/redis/architecture/storage/</link><guid>https://mimus.pgsty.com/docs/redis/architecture/storage/</guid><description>&lt;p&gt;All durable Redis state lives in ordinary WAL-logged PostgreSQL tables inside schema &lt;code&gt;redis&lt;/code&gt;. The Go gateway holds no persistent data of its own.&lt;/p&gt;&#10;&lt;h2 id="keys"&gt;Keyspace and binary identity&#10;&lt;/h2&gt;&#10;&lt;p&gt;Every Redis key has one row in &lt;code&gt;redis._keyspace&lt;/code&gt;:&lt;/p&gt;&#10;&lt;div class="td-code td-code--untitled" id="td-code-2153297f-fence-0" data-td-code data-td-code-auto-id&#10; data-td-language="sql" data-td-line-count="12"&gt;&#10; &lt;div class="td-code__viewport" id="td-code-2153297f-fence-0-viewport" data-td-code-viewport&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;TABLE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyspace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;bigint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;GENERATED&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALWAYS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IDENTITY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;PRIMARY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;integer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;CHECK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;BETWEEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytea&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;CHECK&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;octet_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytea&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;char&amp;#34;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;DEFAULT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;s&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bytea&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;expires&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;bigint&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WITH&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fillfactor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;autovacuum_vacuum_scale_factor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;02&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INDEX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyspace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;INDEX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_keyspace&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expires&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;expires&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;IS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NOT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Digest-indexed lookup:&lt;/strong&gt; Unbounded binary keys (&lt;code&gt;bytea&lt;/code&gt;, up to 512 MiB) never enter a PostgreSQL B-tree index directly. Instead, &lt;code&gt;pg_redis&lt;/code&gt; indexes &lt;code&gt;(db, digest)&lt;/code&gt; using a 32-byte SHA-256 digest, locks the digest bucket, and compares the full &lt;code&gt;key&lt;/code&gt; bytes to resolve hash collisions safely.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Collection child rows:&lt;/strong&gt; Hash fields (&lt;code&gt;redis._hash&lt;/code&gt;), Set members (&lt;code&gt;redis._set&lt;/code&gt;), ZSet members (&lt;code&gt;redis._zset&lt;/code&gt;), Stream groups (&lt;code&gt;redis._stream_group&lt;/code&gt;) and Stream consumers (&lt;code&gt;redis._stream_consumer&lt;/code&gt;) use the same 32-byte &lt;code&gt;digest&lt;/code&gt; + full &lt;code&gt;bytea&lt;/code&gt; comparison rule, referencing &lt;code&gt;redis._keyspace(id)&lt;/code&gt; with &lt;code&gt;ON DELETE CASCADE&lt;/code&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Sorted sets:&lt;/strong&gt; &lt;code&gt;redis._zset&lt;/code&gt; stores &lt;code&gt;score double precision&lt;/code&gt; (rejecting &lt;code&gt;NaN&lt;/code&gt;) and breaks ties by comparing full member bytes.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Lists and length cache:&lt;/strong&gt; &lt;code&gt;redis._list&lt;/code&gt; orders elements by &lt;code&gt;(kid, pos, id)&lt;/code&gt; without putting element &lt;code&gt;value&lt;/code&gt; bytes in a B-tree. Schema &lt;code&gt;0.54&lt;/code&gt; adds &lt;code&gt;redis._list_length(kid, length)&lt;/code&gt;, maintained by statement-level transition-table triggers on &lt;code&gt;redis._list&lt;/code&gt; so &lt;code&gt;LLEN&lt;/code&gt;, &lt;code&gt;LPUSH&lt;/code&gt; and &lt;code&gt;RPUSH&lt;/code&gt; read one row instead of counting every element.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="tables"&gt;Table inventory (schema 0.54)&#10;&lt;/h2&gt;&#10;&lt;div class="td-table-scroll td-table-scroll--static"&gt;&#10;&lt;table class="wide td-table--wide"&gt;&#10; &lt;thead&gt;&#10; &lt;tr&gt;&#10; &lt;th scope="col"&gt;Category&lt;/th&gt;&#10; &lt;th scope="col"&gt;Tables&lt;/th&gt;&#10; &lt;th scope="col"&gt;Purpose&lt;/th&gt;&#10; &lt;/tr&gt;&#10; &lt;/thead&gt;&#10; &lt;tbody&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Keyspace and Strings&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._keyspace&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Logical DB (&lt;code&gt;0&lt;/code&gt;–&lt;code&gt;15&lt;/code&gt;), 32-byte digest, binary key, type tag (&lt;code&gt;s&lt;/code&gt;, &lt;code&gt;h&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;S&lt;/code&gt;, &lt;code&gt;z&lt;/code&gt;, &lt;code&gt;x&lt;/code&gt;), inline payload (&lt;code&gt;value&lt;/code&gt; for Strings, Bitmaps, HLL) and millisecond deadline (&lt;code&gt;expires&lt;/code&gt;)&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Hashes&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._hash&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;(kid, digest, field, value)&lt;/code&gt; rows per hash field&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Lists&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._list&lt;/code&gt;, &lt;code&gt;redis._list_length&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;(kid, pos, value)&lt;/code&gt; element rows and statement-trigger-maintained per-list length cache&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Sets&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._set&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;(kid, digest, member)&lt;/code&gt; rows per set member&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Sorted sets ( and Geo)&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._zset&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;(kid, digest, member, score)&lt;/code&gt; rows; Geo keys store 52-bit geohash integers as ZSet scores&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Streams&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._stream&lt;/code&gt;, &lt;code&gt;redis._stream_entry&lt;/code&gt;, &lt;code&gt;redis._stream_node&lt;/code&gt;, &lt;code&gt;redis._stream_radix&lt;/code&gt;, &lt;code&gt;redis._stream_group&lt;/code&gt;, &lt;code&gt;redis._stream_consumer&lt;/code&gt;, &lt;code&gt;redis._stream_pel&lt;/code&gt;, &lt;code&gt;redis._stream_config&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Stream metadata (&lt;code&gt;last_id&lt;/code&gt;, &lt;code&gt;max_deleted_id&lt;/code&gt;, &lt;code&gt;entries_added&lt;/code&gt;), live entries, listpack nodes, radix tree prefixes, consumer groups, consumers and Pending Entries List (PEL)&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Object metadata&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._object_encoding&lt;/code&gt;, &lt;code&gt;redis._object_heat&lt;/code&gt;, &lt;code&gt;redis._object_shared_heat&lt;/code&gt;, &lt;code&gt;redis._object_reference&lt;/code&gt;, &lt;code&gt;redis._object_config&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Encoding state, optional listpack/quicklist layout (&lt;code&gt;pg_redis.list_layout_tracking&lt;/code&gt;), optional LRU/LFU heat (&lt;code&gt;pg_redis.object_heat_tracking&lt;/code&gt;) and shared-integer tracking&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Transactions&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._transaction_session&lt;/code&gt;, &lt;code&gt;redis._watch&lt;/code&gt;, &lt;code&gt;redis._exec_context&lt;/code&gt;, &lt;code&gt;redis._mutation_stats&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;WATCH&lt;/code&gt; key versions, &lt;code&gt;EXEC&lt;/code&gt; context and per-key mutation counters&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Blocking commands&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._blocked&lt;/code&gt;, &lt;code&gt;redis._block_keys&lt;/code&gt;, &lt;code&gt;redis._ready&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Blocked waiter registrations, watched keys per waiter and committed handoff replies&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Pub/Sub&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._pubsub_session&lt;/code&gt;, &lt;code&gt;redis._pubsub_subscription&lt;/code&gt;, &lt;code&gt;redis._pubsub_message&lt;/code&gt;, &lt;code&gt;redis._notify_config&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Subscriber sessions, channel/pattern/shard bindings, message ring pages and keyspace-event configuration&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Client tracking&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._tracking_client&lt;/code&gt;, &lt;code&gt;redis._tracking_key&lt;/code&gt;, &lt;code&gt;redis._tracking_prefix&lt;/code&gt;, &lt;code&gt;redis._tracking_pending&lt;/code&gt;, &lt;code&gt;redis._tracking_config&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Client-side caching sessions, tracked key digests, &lt;code&gt;BCAST&lt;/code&gt; prefixes and queued invalidations&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Auth and Redis ACL&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._acl_user&lt;/code&gt;, &lt;code&gt;redis._acl_session&lt;/code&gt;, &lt;code&gt;redis._acl_log&lt;/code&gt;, &lt;code&gt;redis._acl_config&lt;/code&gt;, &lt;code&gt;redis._acl_service&lt;/code&gt;, &lt;code&gt;redis._auth_ticket&lt;/code&gt;, &lt;code&gt;redis._auth_key_ticket&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;Redis ACL users, rules, security log and session tickets&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;tr&gt;&#10; &lt;td&gt;Diagnostics and control&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;redis._monitor_client&lt;/code&gt;, &lt;code&gt;redis._client_pause_control&lt;/code&gt;, &lt;code&gt;redis._debug_control&lt;/code&gt;, &lt;code&gt;redis._output_config&lt;/code&gt;, &lt;code&gt;redis._slowlog_config&lt;/code&gt;, &lt;code&gt;redis._encoding_config&lt;/code&gt;, &lt;code&gt;redis._hll_config&lt;/code&gt;, &lt;code&gt;redis._runtime_identity&lt;/code&gt;&lt;/td&gt;&#10; &lt;td&gt;&lt;code&gt;MONITOR&lt;/code&gt; observers, &lt;code&gt;CLIENT PAUSE&lt;/code&gt; deadlines, &lt;code&gt;DEBUG PAUSE-CRON&lt;/code&gt; / &lt;code&gt;SET-ACTIVE-EXPIRE&lt;/code&gt; state, output buffer limits, &lt;code&gt;SLOWLOG&lt;/code&gt; settings and installation identity&lt;/td&gt;&#10; &lt;/tr&gt;&#10; &lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&#10;&lt;h2 id="encoding"&gt;Encoding history and Streams&#10;&lt;/h2&gt;&#10;&lt;p&gt;&lt;code&gt;redis._object_encoding&lt;/code&gt; stores per-key encoding metadata (&lt;code&gt;int&lt;/code&gt;, &lt;code&gt;embstr&lt;/code&gt;, &lt;code&gt;raw&lt;/code&gt;, &lt;code&gt;listpack&lt;/code&gt;, &lt;code&gt;hashtable&lt;/code&gt;, &lt;code&gt;intset&lt;/code&gt;, &lt;code&gt;skiplist&lt;/code&gt;, &lt;code&gt;stream&lt;/code&gt;), and &lt;code&gt;COPY&lt;/code&gt; 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.&lt;/p&gt;</description></item><item><title>Request path</title><link>https://mimus.pgsty.com/docs/redis/architecture/request-path/</link><guid>https://mimus.pgsty.com/docs/redis/architecture/request-path/</guid><description>&lt;p&gt;For an ordinary command outside &lt;code&gt;MULTI&lt;/code&gt;, the gateway executes the command inside a PostgreSQL transaction and waits for PostgreSQL to confirm the commit before writing the RESP reply to the client.&lt;/p&gt;&#10;&lt;h2 id="ordinary"&gt;Ordinary command sequence&#10;&lt;/h2&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;The gateway parses the incoming RESP2 or RESP3 frame and enforces request-header and argument-size budgets.&lt;/li&gt;&#10;&lt;li&gt;The gateway acquires a pooled PostgreSQL connection bound to the authenticated identity.&lt;/li&gt;&#10;&lt;li&gt;The &lt;code&gt;pg_redis&lt;/code&gt; extension verifies function ownership and role capabilities (&lt;code&gt;redis._read()&lt;/code&gt;, &lt;code&gt;redis._write()&lt;/code&gt;, &lt;code&gt;redis._admin()&lt;/code&gt;) and acquires the required database and key locks.&lt;/li&gt;&#10;&lt;li&gt;The extension takes a current snapshot and runs the C command handler against the &lt;code&gt;redis.*&lt;/code&gt; tables.&lt;/li&gt;&#10;&lt;li&gt;PostgreSQL commits the transaction (including a WAL flush when &lt;code&gt;synchronous_commit = on&lt;/code&gt;).&lt;/li&gt;&#10;&lt;li&gt;Once the commit &lt;code&gt;ReadyForQuery&lt;/code&gt; frame arrives, the gateway sends the RESP reply to the client and resets the backend connection before returning it to the pool.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;If the gateway cannot confirm the commit or complete the connection reset, it closes the client and backend connections without replaying the command.&lt;/p&gt;</description></item></channel></rss>