Commands
Supported Redis commands — full matrix, notes, and TTL behaviour.
PostRESP implements a growing Redis command surface over Postgres storage. Status meanings:
| Badge | Meaning |
|---|---|
| Supported | Implemented with Redis-like semantics for the common path |
| Partial | Works for basic usage; some options, types, or edge cases missing |
| Stub | Minimal reply for client/harness compatibility — not a full implementation |
| Not supported | Returns an unknown-command error today |
Redis compatibility is validated against a pinned Valkey test suite (currently 8.1.4). See the live per-test tracker on Compatibility.
Command matrix
Connection & server
| Command | Status | Notes |
|---|---|---|
PING |
Supported | RESP arrays and inline text. Quoted inline arguments follow Redis splitting. An empty line or a non-positive array length is ignored. A malformed request returns Protocol error and closes the connection |
ECHO |
Supported | |
QUIT |
Supported | Returns OK and closes the connection. Later commands in the same buffer are not run |
AUTH |
Supported | Postgres LOGIN role; optional by default (RequireClientAuth: false) |
SELECT |
Partial | Only database 0. Any other integer index is ERR DB index is out of range |
INFO |
Supported | default / all / named sections (cpu, replication, commandstats, errorstats, …); per-command calls, usec, and failed_calls; total_error_replies; live connected_clients, blocked_clients (held until the blocking command is recorded), watching_clients, and total_watched_keys; redis_version matches the Valkey pin; pg_resp_* fields |
HELLO |
Partial | RESP2 only (HELLO / HELLO 2); HELLO 3 → NOPROTO; supports AUTH / SETNAME options |
CLIENT |
Partial | ID, INFO, LIST (filters ID / ADDR / LADDR / TYPE / USER / SKIPME / MAXAGE), REPLY, SETNAME, GETNAME, SETINFO (lib-name / lib-ver), NO-TOUCH ON/OFF, `UNBLOCK id [TIMEOUT |
CONFIG |
Partial | GET takes several patterns. An exact name can see a hidden parameter (key-load-delay); * cannot. slaveof is an alias of replicaof. slowlog-log-slower-than and slowlog-max-len alias the command-log settings and are applied. busy-reply-threshold (lua-time-limit) is a non-negative millisecond count, default 5000, and is applied. SET remembers known parameters and rejects a duplicate name or an immutable one (daemonize, replicaof). databases is refused. requirepass and hll-sparse-max-bytes still take effect. Unknown names stay a no-op. maxmemory must be a memory size (1, 1k, 1kb, 1mb); a bad value is argument must be a memory value and is not stored. GET returns the byte count. Remembered maxmemory, save, and bind are not applied as eviction, AOF, or a listen address. RESETSTAT clears command, error, and expiry counters |
SLOWLOG |
Partial | GET / LEN / RESET / HELP. Each entry is id, unix time, microseconds, the original argument vector, client address, and client name. Arguments are trimmed at 32 and 128 bytes. EXEC is not logged. A blocked command is logged when it finishes. ACL, AUTH, and MIGRATE fields are not redacted |
COMMANDLOG |
Partial | GET / LEN / RESET for slow, large-request, and large-reply. The slow log is SLOWLOG. Request size is the sum of argument bytes; reply size is the encoded reply |
FUNCTION |
Partial | LOAD / LIST / DELETE / STATS / FLUSH / DUMP / RESTORE and FCALL / FCALL_RO. Libraries run in a process-local Lua state (server.register_function, shebang name=). DUMP / RESTORE round-trip library source in a PostRESP payload (not a Valkey RDB snapshot); policies are APPEND (default), REPLACE, and FLUSH. FUNCTION KILL stops a running function. SCRIPT KILL during a function returns BUSY and does not stop it |
COMMAND |
Partial | COUNT / LIST / INFO / GETKEYS / GETKEYSANDFLAGS / DOCS / HELP advertise implemented commands, including XRANGE. Key flags cover read-only access, overwrite, and LMOVE / SORT STORE |
FLUSHDB |
Supported | |
FLUSHALL |
Supported |
Strings & keys
| Command | Status | Notes |
|---|---|---|
SET |
Supported | NX / XX / GET / IFEQ / EX / PX / EXAT / PXAT / KEEPTTL; overwrites other types (GET/IFEQ still WRONGTYPE) |
SETNX |
Supported | |
SETEX / PSETEX |
Supported | |
GET |
Supported | Binary-safe; empty string ≠ missing key |
GETDEL |
Supported | |
GETEX |
Supported | |
GETSET |
Supported | |
DEL |
Supported | |
UNLINK |
Supported | Same as DEL today (synchronous delete; reply is deleted count) |
RENAME |
Supported | Overwrites dest; moves TTL |
RENAMENX |
Supported | Integer 1 if renamed, 0 if dest exists; missing source is an error |
COPY |
Partial | Same DB only (SELECT 0); REPLACE; copies TTL, including stream entries, groups, consumers, and the pending list. DB other than 0 is out of range |
EXISTS |
Supported | |
TOUCH |
Supported | Returns how many of the keys exist, and refreshes their idle time. Also works from EVAL |
OBJECT |
Partial | IDLETIME is seconds since the last SET, GET, or TOUCH in this process. REFCOUNT is 1 for an existing key (values are not shared). A missing key is a null bulk. ENCODING, FREQ, and HELP are not implemented |
TYPE |
Supported | none / string / list / set (hash when hash storage exists). Does not refresh idle time |
KEYS |
Partial | Redis glob (*, ?, \, […] classes). Nested * stops at Valkey’s depth cap instead of hanging. Expensive — prefer SCAN for large keyspaces |
RANDOMKEY |
Supported | Null bulk when DB is empty |
STRLEN |
Supported | |
APPEND |
Supported | |
GETRANGE / SUBSTR |
Supported | SUBSTR aliases GETRANGE |
SETRANGE |
Supported | |
MGET / MSET / MSETNX |
Supported | |
INCR / DECR / INCRBY / DECRBY |
Supported | |
INCRBYFLOAT |
Supported | |
DBSIZE |
Supported | |
MEMORY USAGE |
Partial | Approximate payload size (key + value) |
SETBIT / GETBIT |
Supported | |
BITCOUNT / BITPOS |
Supported | Optional start/end and BYTE/BIT |
BITOP |
Supported | AND / OR / XOR / NOT |
BITFIELD / BITFIELD_RO |
Supported | GET / SET / INCRBY; OVERFLOW WRAP / SAT / FAIL; # offsets |
LCS |
Supported | |
PFADD / PFCOUNT / PFMERGE |
Supported | Sparse and dense HYLL strings; PFDEBUG / PFSELFTEST; hll-sparse-max-bytes |
Hashes
| Command | Status | Notes |
|---|---|---|
HSET / HMSET |
Supported | Variadic field/value pairs; HMSET is legacy OK reply |
HSETNX |
Supported | |
HGET / HMGET |
Supported | Missing fields → null bulk |
HDEL |
Supported | Empty hash deletes the key |
HEXISTS / HLEN |
Supported | |
HGETALL / HKEYS / HVALS |
Supported | |
HINCRBY |
Supported | Integer field increment |
HINCRBYFLOAT |
Supported | Float field increment; non-finite increment is rejected before the key is created |
HSTRLEN |
Supported | Byte length of a field; 0 if missing |
HRANDFIELD |
Supported | Optional count (unique if ≥0, with replacement if negative) + WITHVALUES |
HSCAN |
Supported | MATCH / COUNT / NOVALUES; keyset cursor (inserts and deletes of other fields do not skip fields that remain) |
| Other hash commands | Not supported | Field TTL / HGETEX |
Sets
| Command | Status | Notes |
|---|---|---|
SADD |
Supported | Returns newly added member count |
SREM |
Supported | Deletes key when the set becomes empty |
SISMEMBER |
Supported | |
SMISMEMBER |
Supported | |
SCARD |
Supported | |
SMEMBERS |
Supported | |
SPOP |
Partial | Optional count; random member(s); no replication rewrite |
SRANDMEMBER |
Supported | Optional count (unique if ≥0, with replacement if negative) |
SUNION / SINTER / SDIFF |
Supported | Missing keys treated as empty |
SUNIONSTORE / SINTERSTORE / SDIFFSTORE |
Supported | Overwrites dest; empty result deletes dest |
SMOVE |
Supported | |
SINTERCARD |
Supported | Optional LIMIT |
SSCAN |
Supported | MATCH / COUNT; keyset cursor (inserts and deletes of other members do not skip members that remain) |
| Other set commands | Not supported |
Lists
| Command | Status | Notes |
|---|---|---|
LPUSH / RPUSH |
Supported | Variadic |
LPUSHX / RPUSHX |
Supported | No-op (0) if the key is missing |
LPOP / RPOP |
Supported | Optional count. Count 0 on an existing list is an empty array; a missing key is null |
LLEN |
Supported | |
LRANGE |
Supported | |
LINDEX |
Supported | |
LTRIM |
Supported | Empty result deletes the key |
LSET |
Supported | ERR no such key / ERR index out of range |
LREM |
Supported | Count head/tail/all semantics |
LINSERT |
Supported | BEFORE / AFTER |
LPOS |
Supported | RANK / COUNT / MAXLEN. COUNT returns an array; a bare search returns one index or a null bulk |
RPOPLPUSH |
Supported | |
LMOVE |
Supported | LEFT / RIGHT source and dest |
BLPOP / BRPOP |
Supported | The writer serves blocked clients, oldest first, before its reply. A pipelined command after LPUSH sees the list after those clients. INFO blocked_clients. Non-blocking inside MULTI/EVAL |
BLMOVE / BRPOPLPUSH |
Supported | Blocks on the source. A wrong-type destination is WRONGTYPE and the source is unchanged, so the next waiter can take the element. A successful move serves waiters on the destination before the writer returns. Timeout is a null bulk |
LMPOP / BLMPOP |
Supported | numkeys key… LEFT|RIGHT [COUNT n]; nested [key, [elements…]]. Blocked clients are served oldest first and each takes the first of its keys that has elements. BLMPOP timeout first |
SORT / SORT_RO |
Supported | Lists, sets, and sorted sets. BY key or key->field, GET, LIMIT, ASC/DESC, ALPHA, STORE. nosort keeps native order. Equal weights break ties lexicographically. SORT_RO rejects STORE |
Sorted sets
| Command | Status | Notes |
|---|---|---|
ZADD |
Supported | NX / XX / GT / LT / CH / INCR |
ZINCRBY |
Supported | Creates the key/member as needed |
ZREM / ZCARD / ZSCORE / ZMSCORE |
Supported | ZSCORE prints a long decimal with Redis %.17g (DBL_MAX is 1.7976931348623157e+308) |
ZRANK / ZREVRANK |
Supported | Optional WITHSCORE |
ZRANGE |
Supported | BYSCORE / BYLEX / REV / LIMIT / WITHSCORES. REV swaps score and lex bounds only |
ZREVRANGE |
Supported | Rank indexes only; optional WITHSCORES |
ZRANGESTORE |
Supported | Same range syntax as ZRANGE (no WITHSCORES). Replaces dest and clears TTL; empty or missing source deletes dest; wrong-type source leaves dest unchanged |
ZRANGEBYSCORE / ZREVRANGEBYSCORE |
Partial | LIMIT; WITHSCORES |
ZRANGEBYLEX / ZREVRANGEBYLEX |
Supported | - / + / [ / ( bounds; LIMIT |
ZLEXCOUNT / ZREMRANGEBYLEX |
Supported | |
ZRANDMEMBER |
Supported | Optional count + WITHSCORES |
ZSCAN |
Supported | MATCH / COUNT / NOSCORES; keyset cursor; scores use score::text |
ZCOUNT / ZPOPMIN / ZPOPMAX |
Supported | |
ZMPOP |
Supported | Nested [key, [[member, score], …]]; MIN/MAX/COUNT |
BZMPOP |
Supported | timeout numkeys key… MIN|MAX [COUNT n]. The writer serves blocked clients, oldest first, before its reply. Each client takes the first of its keys that has members |
ZUNION / ZINTER / ZDIFF |
Supported | WEIGHTS / AGGREGATE / WITHSCORES (ZDIFF has no weights). A set is accepted and scores as 1 |
ZUNIONSTORE / ZINTERSTORE / ZDIFFSTORE |
Supported | Overwrites dest; empty result deletes dest |
ZINTERCARD |
Supported | Optional LIMIT |
ZREMRANGEBYRANK / ZREMRANGEBYSCORE |
Supported | |
BZPOPMIN / BZPOPMAX |
Supported | The writer serves blocked clients, oldest first, before its reply. INFO blocked_clients. Non-blocking inside MULTI/EVAL |
Geo
| Command | Status | Notes |
|---|---|---|
GEOADD |
Supported | Redis 52-bit WGS84 geohash scores on a zset; NX / XX / CH |
GEOHASH |
Supported | 11-char geohash; missing members are null bulks |
GEOPOS |
Supported | Decoded cell-center coordinates; missing members are null arrays |
GEODIST |
Supported | m / km / ft / mi; 4 decimal places |
GEORADIUS / GEORADIUS_RO |
Supported | WITHDIST / WITHHASH / WITHCOORD / COUNT / ANY / ASC/DESC; STORE/STOREDIST (write form) |
GEORADIUSBYMEMBER / GEORADIUSBYMEMBER_RO |
Supported | Same options as GEORADIUS |
GEOSEARCH |
Supported | FROMMEMBER/FROMLONLAT + BYRADIUS/BYBOX; brute-force scan of the zset |
GEOSEARCHSTORE |
Supported | Overwrites dest; optional STOREDIST |
Streams
| Command | Status | Notes |
|---|---|---|
XADD |
Partial | Auto-ID * and ms-*; NOMKSTREAM; optional MAXLEN / MINID / = / ~ (exact trim; node-size ~ not emulated) |
XLEN |
Supported | Missing key → 0 |
XRANGE / XREVRANGE |
Supported | - / + / incomplete IDs / exclusive (; optional COUNT |
XDEL |
Supported | Empty stream keeps the key |
XTRIM |
Partial | MAXLEN and MINID (exact; node-size ~ not emulated) |
XREAD |
Partial | COUNT / BLOCK; $ latest; + last entry, including a blocked read of an empty stream. Blocking wakes are process-local |
XINFO |
Partial | STREAM / STREAM FULL / GROUPS / CONSUMERS / HELP. entries-read and lag follow Valkey (null when a tombstone makes the counter unknowable) |
XSETID |
Supported | ENTRIESADDED / MAXDELETEDID |
XGROUP |
Partial | CREATE (MKSTREAM, ENTRIESREAD, $), SETID, DESTROY, CREATECONSUMER, DELCONSUMER, HELP. No HELP extras |
XREADGROUP |
Partial | GROUP, COUNT, BLOCK, NOACK, >. History is exclusive. Blocking clients run in block order and drop their waiter when the connection closes |
XACK / XPENDING |
Supported | XACK checks every id before removing any. XPENDING summary and IDLE / exclusive ranges |
XCLAIM / XAUTOCLAIM |
Partial | IDLE / TIME / RETRYCOUNT / FORCE / JUSTID / LASTID. XAUTOCLAIM cursor stops on COUNT |
TTL / expiry
| Command | Status | Notes |
|---|---|---|
EXPIRE / PEXPIRE |
Supported | NX / XX / GT / LT; lazy + active purge |
EXPIREAT / PEXPIREAT |
Supported | Absolute unix seconds / milliseconds |
EXPIRETIME / PEXPIRETIME |
Supported | |
TTL / PTTL |
Supported | |
PERSIST |
Supported | |
TIME |
Supported | Server clock for clients / harnesses |
DELEX |
Supported | IFEQ only (safe lock unlock); not IFNE / digest |
SCAN |
Supported | Keyset cursor + MATCH / COUNT / TYPE (string/list/set/zset/hash/stream). Keys that stay present for the whole iteration are not skipped when other keys are added or removed. MATCH uses the same glob as KEYS |
Pub/Sub
| Command | Status | Notes |
|---|---|---|
PUBLISH |
Supported | In-process fan-out (single gateway instance) |
SUBSCRIBE / UNSUBSCRIBE |
Supported | RESP2 subscribed-mode filter; RESP2 PING → ["pong", …]; RESP3 PING normal |
PSUBSCRIBE / PUNSUBSCRIBE |
Supported | Redis glob patterns (*, ?, \, […]) |
PUBSUB |
Supported | CHANNELS / NUMSUB / NUMPAT / HELP |
CLIENT REPLY |
Supported | ON / OFF / SKIP — silences command replies; pub/sub pushes still delivered |
CLIENT SETNAME / GETNAME |
Supported | Per-connection name. Empty clears. Spaces, newlines, and other non-printable bytes are rejected |
CLIENT SETINFO |
Supported | lib-name / lib-ver (Lettuce handshake). Empty string clears. Spaces and newlines are rejected separately |
CLIENT ID / INFO / LIST |
Supported | Process-local. LIST filters ID, ADDR, LADDR, TYPE, USER, SKIPME, MAXAGE. Open mode reports user=default |
Known limitation — process-local delivery
Pub/Sub fan-out is in-process only (one hub per gateway process). That matches the default single-instance / in-process RESP path: every client shares the same BGWorker.
If you later run multiple gateway processes against one Postgres (several
standalone redis_gateway pods, or more than one RESP listener), a PUBLISH on
instance A will not reach subscribers on instance B until we add a
cross-process bus — typically PostgreSQL LISTEN/NOTIFY on a single broadcast
channel. Key/value data already shared via SQL is unaffected; only live
subscription delivery is process-scoped today.
Scripting
| Command | Status | Notes |
|---|---|---|
EVAL |
Partial | Lua 5.1; KEYS/ARGV; redis.call/pcall; globals and library tables are read-only; os.clock only; #!lua flags=no-writes rejects writes. A #! line must name the lua engine; unknown options and flags are rejected. A shebang without no-writes cannot run on EVAL_RO. The script runs in a Postgres transaction when storage is available. Wrong arity is ERR Wrong number of args calling command from script. Non-string arguments are rejected. CLUSTER is not allowed from a script. error() replies follow Valkey: ERR user_script:<line>: … script: <sha>, on @user_script:<line>. redis.error_reply with no error code is prefixed with ERR ("" is ERR). A failed script rolls the Postgres transaction back. Blocking reads of empty keys return null instead of waiting. A reply nested more than 64 tables, including a cycle, ends with ERR reached lua stack limit |
EVAL_RO / EVALSHA_RO |
Supported | Same as EVAL / EVALSHA, but write commands raise Write commands are not allowed from read-only scripts |
EVALSHA |
Partial | Process-local SHA1 cache; NOSCRIPT when missing |
SCRIPT LOAD / EXISTS / FLUSH / SHOW |
Supported | In-process cache (like Redis); FLUSH ASYNC|SYNC accepted; SHOW returns the source or NOSCRIPT; INFO memory reports number_of_cached_scripts |
SCRIPT KILL / DEBUG |
Partial | KILL stops a read-only script once busy-reply-threshold has elapsed. Idle is NOTBUSY. A script that already wrote is UNKILLABLE. KILL during FCALL returns BUSY. DEBUG → OK |
bit.* |
Partial | LuaBitOp-style tobit/bnot/band/bor/bxor/lshift/rshift/arshift/rol/ror/bswap/tohex (tohex clamps INT32_MIN) |
cjson.encode / decode |
Partial | lua-cjson 2.1 arrays vs objects, encode_max_depth / decode_max_depth, encode_invalid_numbers, cjson.null. decode of nan is not accepted |
cmsgpack.pack / unpack |
Partial | Redis lua_cmsgpack types (nil → Lua nil, not userdata); unpack_one / unpack_limit; bin strings accepted. Large maps are packed one field at a time so they do not exhaust the Lua stack |
Nested EVAL / pubsub-subscribe / MULTI from scripts |
Not supported | Rejected like Redis |
Transactions
| Command | Status | Notes |
|---|---|---|
MULTI / EXEC / DISCARD |
Partial | Queues on the connection; EXEC runs one Postgres txn. A dirty WATCH aborts EXEC with a null array. During a timed-out script, MULTI and DISCARD are allowed; a queued command is BUSY and EXEC is EXECABORT |
WATCH / UNWATCH |
Supported | Per-connection CAS. A write, EXPIRE, or FLUSHDB/FLUSHALL of an existing watched key fails the next EXEC. DISCARD and a finished EXEC clear watches |
Not yet implemented (families)
| Area | Status | Notes |
|---|---|---|
| Hashes | Partial | Field basics + HINCRBY/HINCRBYFLOAT/HSTRLEN/HRANDFIELD/HSCAN; no field TTL |
| Sets | Partial | Basics + union/inter/diff + STORE + SMOVE + SRANDMEMBER/SINTERCARD/SSCAN |
| Sorted sets | Partial | Core read/write + ZADD options + union/inter/diff + ZINCRBY/ZRANK/ZMSCORE/ZPOPMAX + lex + ZRANDMEMBER/ZSCAN + ZMPOP + ZRANGE BYSCORE/BYLEX/REV + ZRANGESTORE. SORT / SORT_RO cover lists, sets, and sorted sets |
| Streams | Partial | XADD/XLEN/XRANGE/XREVRANGE/XDEL/XREAD/XTRIM/XINFO/XSETID plus consumer groups (XGROUP/XREADGROUP/XACK/XPENDING/XCLAIM/XAUTOCLAIM). No DUMP/RESTORE. IDs stored as signed bigint |
| Keyspace notifications | Not supported | |
| Sharded pub/sub | Not supported | |
| Scripting extras | Partial | EVAL/EVAL_RO/EVALSHA/EVALSHA_RO/SCRIPT SHOW + FCALL/FUNCTION (LOAD/LIST/DELETE/STATS/FLUSH/DUMP/RESTORE) + cjson/cmsgpack/bit + SCRIPT KILL / FUNCTION KILL of a read-only script; not replication, script LRU, or SHUTDOWN NOSAVE |
| Clustering / replication admin | Not supported | Single logical DB (SELECT 0) |
Distributed locks
Single-node Redis-style locks work without Lua or with classic Redlock Lua:
| Step | Command | Notes |
|---|---|---|
| Acquire | SET resource_name <unique-token> NX PX <ttl-ms> |
Null bulk if already held |
| Refresh | SET resource_name <unique-token> IFEQ <unique-token> PX <ttl-ms> |
Extends TTL only while you still hold the token |
| Unlock (native) | DELEX resource_name IFEQ <unique-token> |
Integer 1 deleted / 0 if token mismatch or missing |
| Unlock (Lua) | EVAL compare-and-DEL (Infisical / node-redlock style) |
Supported via EVAL/EVALSHA |
Use a random per-acquire token so an expired holder cannot delete another
client’s lock. Prefer DELEX IFEQ over DEL / GET+DEL when you control
the client; Lua unlock scripts used by Redlock libraries also work. SQL storage
serializes per-key mutations (pgresp.lock_key) so concurrent SET NX and
DELEX IFEQ stay atomic across sessions. Scripted unlocks run inside a Postgres
transaction for the duration of EVAL.
TTL / expiry
- Lazy — expiry checked on read/write paths so stale keys are not returned.
- Active —
pg_cronperiodically batch-deletes expired rows.
Known limitation — naive active expiry
| Path | What we do now | Gap vs Redis |
|---|---|---|
SQL (pg_cron) |
Delete up to batch × rounds rows per minute |
Coarser than Redis sampling cadence |
SQL sweeper GUCs:
| GUC | Default | Meaning |
|---|---|---|
pg_resp.ttl_delete_batch_size |
1000 |
Keys per DELETE round |
pg_resp.ttl_delete_max_rounds |
10 |
Rounds per CALL pgresp.delete_expired_keys() |
Correctness (lazy-on-access + eventual active delete) is fine. Cost under very large key counts is not — raise the GUCs to drain backlogs faster, or prefer access patterns that rely on lazy expiry.