Redis (RESP) implementation reference
This page describes how the Redis wire is built: framing, authentication, the command dispatch table, how keys map onto storage, durability, errors, limits and tests. For ports, the proof scores, how to connect and how to re-run the differential suites, see the operator page Redis. Authentication policy across all wires is in Security.
Code lives in src/protocol/redis/: mod.rs (listener and connection loop), resp.rs (codec), commands.rs (the CommandExecutor and most commands), commands/ (persist.rs, acl.rs, acl_table.rs, json.rs, search.rs, geo.rs, rdb.rs), scripting.rs and lua_libs.rs (Lua).
Listener and connection loop
-
RedisHandler::startbinds aTcpListener, setsTCP_NODELAYon every accepted socket and spawns one task per connection. The default port is 6379 (ProtocolHandler::default_port;server_portdefaultredis_port = Some(6379)insrc/config.rs). (source:src/protocol/redis/mod.rs,RedisHandler::start;src/config.rs) - The server builds the handler with
RedisHandler::with_storage, orRedisHandler::with_tlswhen a TLS config exists.with_storageloads the whole persisted keyspace into memory withload_redis_sharedand, in cluster mode, registers aRedisReplicaSynclistener so writes replicated from other nodes reach memory. (source:src/server/mod.rs;src/protocol/redis/mod.rs,RedisHandler::with_storage) - TLS on this wire is implicit: when configured, every connection is wrapped with
TlsListener::acceptbefore any RESP byte is read, so a plaintext client cannot use the same port. It does not use the first-byte detection (accept_auto) that some other wires use. (source:src/protocol/redis/mod.rs,RedisHandler::start;src/protocol/tls.rs,TlsListener::accept_auto) Not verified: no Rust test covers Redis over TLS. - One
CommandExecutorper connection, created withCommandExecutor::with_sharedover the server-wideRedisShared(16 databases, ACL store, isolation gate) and the shared pub/sub registry. (source:src/protocol/redis/mod.rs,handle_connection) - Replies are written to a 64 KiB
BufWriterand flushed before the loop waits for the next command, so a pipelined batch is answered with one write. (source:src/protocol/redis/mod.rs,handle_connection) - Timeouts come from
TimeoutConfig::default(): read 60 s, write 60 s, idle 300 s. The idle timeout is not enforced while the connection is subscribed to a channel or pattern. A read timeout closes the connection. (source:src/protocol/timeout.rs,TimeoutConfig::default;src/protocol/redis/mod.rs,handle_connection) -
QUITis answered+OK, flushed, and the connection closes.SYNCandPSYNCare handled in the loop, not in the executor: after the auth and ACL checks they send a full RDB snapshot (PSYNCfirst sends+FULLRESYNC <40 hex> 0) and close the connection. No replication stream follows. Stream keys are left out of the snapshot and a warning is logged. (source:src/protocol/redis/mod.rs,handle_connection;src/protocol/redis/commands/rdb.rs)
Framing (RESP2 and RESP3)
Reading requests
RedisHandler::read_command reads one request into a buffer by its first byte, and parse_command turns it into a Vec<RespValue>:
| First byte | Treated as |
|---|---|
* |
RESP array of bulk strings (the normal client form). A negative count is a null array. |
$ |
A single bulk string used as a one-word command. |
+, -, :
|
A single simple value used as a command. |
| anything else | An inline command: the line split on whitespace. |
(source: src/protocol/redis/mod.rs, RedisHandler::read_command, RedisHandler::parse_command)
The decoder in resp.rs also understands the RESP3 types _ null, # boolean, , double, ( big number, ! bulk error, = verbatim string, % map, ~ set, | attribute and > push (source: src/protocol/redis/resp.rs, RespDecoder::decode). Requests only ever use arrays of bulk strings in practice.
Writing replies
The executor builds replies as RespValue (SimpleString, Error, Integer, BulkString, Array, Null, Boolean, Double, BigNumber, BulkError, Map, Set, Push, Attribute). RespEncoder::encode_versioned(value, proto) encodes them for the negotiated protocol:
- RESP3 (
proto >= 3,encode_to_v3): null bulk strings and null arrays become_; maps use%, sets~, pushes>, attributes|. - RESP2 (
encode_to_v2): RESP3-only types are down-converted:Nullbecomes$-1,Booleanbecomes:1/:0,DoubleandBigNumberbecome bulk strings, maps and sets are flattened to arrays.
(source: src/protocol/redis/resp.rs, RespEncoder::encode_versioned, encode_to_v3, encode_to_v2) Tested by the 18 unit tests in src/protocol/redis/resp.rs.
Under RESP3, resp3_reshape re-types replies the way Redis does after HELLO 3: maps from HGETALL and similar, sets from SMEMBERS and similar, doubles for scores, and [member, score] pairs for WITHSCORES. Pub/sub messages are delivered as RESP3 > pushes, or as plain * arrays under RESP2, and split_subscription_replies splits a multi-channel SUBSCRIBE reply into one frame per channel. (source: src/protocol/redis/mod.rs, resp3_reshape, split_subscription_replies)
Authentication
The default: fail closed
The Redis wire requires AUTH by default. The README says Redis accepts unauthenticated clients unless SYNERGYDB_REDIS_REQUIREPASS is set (source: README.md, "Security defaults"), and the doc comment on configured_requirepass repeats that ("None / empty means no password is required – the server is open"). The code does not do that:
-
CommandExecutor::with_shared(the constructor the connection loop uses) setsauthenticated: crate::auth::wire_auth::dev_insecure_auth_enabled(). That function returns true only when the environment variableSYNERGYDB_DEV_INSECURE_AUTHis1ortrue. With it unset, every new connection starts unauthenticated, whether or notSYNERGYDB_REDIS_REQUIREPASSis set. If an ACL entry fordefaultexists and is off or has its own password, the connection also starts unauthenticated. -
CommandExecutor::requires_auththen refuses every command exceptAUTH,HELLO,QUITandRESETwithNOAUTH Authentication required.whileauthenticatedis false. It is called fromexecute_innerbefore dispatch, the single chokepoint for all commands.PINGis refused too.
So the function that decides the default is crate::auth::wire_auth::dev_insecure_auth_enabled, read once per connection in CommandExecutor::with_shared, and enforced by CommandExecutor::requires_auth. (source: src/protocol/redis/commands.rs, CommandExecutor::with_shared, CommandExecutor::requires_auth, configured_requirepass; src/auth/wire_auth.rs, dev_insecure_auth_enabled) This matches the status entries docs/status/2026-11-24-config-env-tls-protected-mode.md and docs/status/2026-11-30-redis-acl-users.md, and contradicts README.md.
Tested by test_no_password_configured_fails_closed, demo_credentials_are_not_a_backdoor, test_requirepass_gates_commands_until_auth and test_requirepass_hello_auth_and_reset in src/protocol/redis/commands.rs. Those tests set the authenticated field directly rather than reading the environment; no test starts a full server without SYNERGYDB_DEV_INSECURE_AUTH and connects to it.
Protected mode. When the dev opt-in makes a connection start authenticated, protected_mode_refuses refuses it unless the peer is loopback (IPv4, IPv6 or IPv4-mapped), sending -DENIED SynergyDB is running in protected mode ... and closing. Protected mode is on by default (PROTECTED_MODE starts true; [server] protected_mode, SYNERGYDB_SERVER_PROTECTED_MODE). (source: src/auth/wire_auth.rs, protected_mode_refuses, PROTECTED_MODE_DENIED; src/protocol/redis/mod.rs, handle_connection) Tested by protected_mode_only_refuses_open_remote_connections in src/auth/wire_auth.rs.
AUTH
AUTH <password> uses user default; AUTH <user> <password> names a user. CommandExecutor::auth checks, in order:
| Step | Condition | Result |
|---|---|---|
| 1 |
SYNERGYDB_TEST_AUTH_CHEAP=1 (test harness switch, read once) |
Any credentials accepted. |
| 2 | The user has a Redis ACL entry that is off
|
WRONGPASS invalid username-password pair or user is disabled. |
| 3 | The ACL entry has its own password(s) or nopass
|
Only those credentials. nopass never opens the built-in default user. For default, the requirepass password also works. |
| 4 |
SYNERGYDB_REDIS_REQUIREPASS is set |
It is the only credential, and only for user default. Catalog roles cannot log in on Redis. |
| 5 | Otherwise |
verify_wire_credential("redis", ...): a SynergyDB catalog role and password, which must be a superuser or a member of synergy_wire_redis or synergy_wire_all (unless SYNERGYDB_WIRE_ACCESS=open). The legacy hash map behind it ships empty. |
Failures are written to the ACL log. Every password check through the catalog goes through note_auth_result, which delays failed answers after 5 consecutive failures for one user name (200 ms doubling, capped at 5 s, window 10 minutes). The requirepass comparison is constant-time (ct_eq). (source: src/protocol/redis/commands.rs, CommandExecutor::auth, get_redis_auth_hashes, redis_cheap_auth, ct_eq; src/auth/wire_auth.rs, verify_wire_credential, wire_access_allowed, note_auth_result) Tested by delay_starts_after_free_failures_and_is_capped and success_clears_the_count in src/auth/wire_auth.rs.
HELLO and RESET
-
HELLO [2|3] [AUTH user pass] [SETNAME name]: a version other than 2 or 3 answersNOPROTO unsupported protocol version. TheAUTHclause runs the sameauthpath. If the connection is still unauthenticated afterwards, HELLO answersNOAUTH HELLO must be called with the client already authenticated ...and the protocol is not switched. On success the reply is a map:server=redis,version=7.4.0,proto,id,mode=standalone,role=master,modules=[]. (source:src/protocol/redis/commands.rs,CommandExecutor::hello,hello_reply) -
RESETclears MULTI state and subscriptions, selects database 0, returns to RESP2, clears the client name and logs the connection out (authenticated = false, userdefault). (source:src/protocol/redis/commands.rs,CommandExecutor::reset) Tested bytest_requirepass_hello_auth_and_reset.
ACL users
ACL SETUSER, GETUSER, DELUSER, USERS, LIST, WHOAMI, CAT, GENPASS, DRYRUN, LOG and HELP are implemented in commands/acl.rs. ACL SAVE and ACL LOAD return Redis's "not configured to use an ACL file" error. (source: src/protocol/redis/commands/acl.rs, acl_command)
- Users are persisted under the storage key prefix
__redisacl__:<name>, so they survive restart withoutACL SAVE. Passwords are stored as unsalted hex SHA-256 (hash_password), the same scheme Redis uses. The ACL log holds at most 128 entries. (source:src/protocol/redis/commands/acl.rs,ACL_PREFIX,hash_password,ACL_LOG_MAX) - Command categories, arity and key positions come from
acl_table.rs, generated from theCOMMANDandACL CATreplies of Redis 8.12 bytest-scripts/diff-redis/gen_acl_table.py. (source:src/protocol/redis/commands/acl_table.rs, header) - A user with rules but no password of its own logs in with the password of the SynergyDB role of the same name and gets only what its rules allow. A login with no ACL entry has full access. (source:
src/protocol/redis/commands/acl.rs, module comment) -
acl_refusalruns before every command exceptAUTH/HELLO/QUIT/RESET, and for everyredis.callinside Lua. A refusal insideMULTIaborts the transaction; a refusedEXECanswersEXECABORT Transaction discarded because of: ...; inside a script the error isERR ACL failure in script: ....refresh_aclre-reads the entry after any ACL change and logs out a connection whose own native user was deleted. (source:src/protocol/redis/commands.rs,acl_refusal,refresh_acl,execute_inner)
Tested by 8 unit tests in src/protocol/redis/commands/acl.rs, and by the ACL differential suite against Redis 8 (341/341, docs/status/2026-11-30-redis-acl-users.md).
src/auth/acl.rs is a different thing: the PostgreSQL-style aclitem model (AclMode, Acl, ColumnAcl) used for SQL privileges. Redis ACL users do not use it. (source: src/auth/acl.rs)
Execution model
CommandExecutor::execute wraps execute_inner:
-
Isolation gate.
RedisShared::isolationis atokio::sync::RwLock<()>. Every command takes it shared;EXEC(inside a transaction) andEVAL,EVALSHA,EVAL_RO,EVALSHA_RO,FCALL,FCALL_ROtake it exclusively, so no other client's command runs between the commands of a transaction or script. Blocking commands take the gate per attempt inside their wait loop. (source:src/protocol/redis/commands.rs,CommandExecutor::execute;src/protocol/redis/commands/persist.rs,RedisShared::isolation) -
Crash-atomic batches. For
EXECand scripts with storage attached,begin_tx_writesholds back every storage write;commit_tx_writessends them as onewrite_batch(one WAL record, one commit marker), then one sync, before the reply. If the batch fails, the touched keys are reloaded from storage and the client gets an error. (source:src/protocol/redis/commands/persist.rs,begin_tx_writes,commit_tx_writes;docs/status/2026-11-30-crash-atomic-redis-bolt.md) - Inside
execute_inner: refresh ACL, auth gate, ACL check, MULTI queueing (every command exceptMULTI,EXEC,DISCARD,WATCH,UNWATCH,RESET,QUITis queued and answered+QUEUED), a cluster replica check (a write on a read-only node answersREADONLY You can't write against a read only replica.and names the leader),before_write(takes the 256 striped per-key locks for the keys the command writes), dispatch,after_write(persists), and an audit record when the audit log is on. (source:src/protocol/redis/commands.rs,execute_inner,is_write_command,before_write,audit_command)
The README and the operator page still say MULTI/EXEC is not isolated from other clients and that a script or MULTI/EXEC can come back half-applied after kill -9. The code at 8a689c5c has both the exclusive isolation gate and the batched commit described above. Not verified: no Rust test covers either; the evidence is the crash test test-scripts/crash/atomic_txn_crash_test.py reported in docs/status/2026-11-30-crash-atomic-redis-bolt.md (old code 0/4, fix 8/8), and that script is not in the reviewed snapshot.
WATCH records the value of each watched key only when it is a string (other types are recorded as absent), and EXEC compares values. A change to a list, hash, set or sorted set under a watched key is therefore not detected, and neither is a string set back to its old value. (source: src/protocol/redis/commands.rs, watch, exec) Not verified: no test covers WATCH on non-string keys.
Command dispatch
The dispatch match in CommandExecutor::execute_inner is the list of supported commands. Anything else answers ERR unknown command '<NAME>'. (source: src/protocol/redis/commands.rs, execute_inner)
| Group | Commands |
|---|---|
| Connection |
PING, ECHO, QUIT, SELECT, AUTH, HELLO, ACL, RESET, CLIENT, INFO, COMMAND, CONFIG, DBSIZE
|
| Strings |
GET, SET, SETNX, SETEX, PSETEX, MGET, MSET, MSETNX, INCR, INCRBY, DECR, DECRBY, INCRBYFLOAT, APPEND, STRLEN, GETRANGE, SETRANGE, GETEX, GETSET, GETDEL
|
| Bitmaps |
GETBIT, SETBIT, BITCOUNT, BITOP, BITPOS
|
| Keys |
DEL, UNLINK (same as DEL), EXISTS, KEYS, TYPE, RENAME, RENAMENX, COPY, TTL, PTTL, EXPIRE, PEXPIRE, EXPIREAT, PEXPIREAT, EXPIRETIME, PEXPIRETIME, PERSIST, SCAN, DUMP, RESTORE, RESTORE-ASKING
|
| Lists |
LPUSH, RPUSH, LPUSHX, RPUSHX, LPOP, RPOP, BLPOP, BRPOP, LLEN, LRANGE, LINDEX, LSET, LTRIM, LREM, LINSERT, LPOS, LMOVE, BLMOVE, RPOPLPUSH, BRPOPLPUSH
|
| Hashes |
HGET, HSET, HSETNX, HMSET, HMGET, HDEL, HGETALL, HKEYS, HVALS, HLEN, HEXISTS, HINCRBY, HINCRBYFLOAT, HRANDFIELD, HSTRLEN, HSCAN
|
| Sets |
SADD, SREM, SMEMBERS, SISMEMBER, SMISMEMBER, SCARD, SINTER, SINTERCARD, SUNION, SDIFF, SRANDMEMBER, SPOP, SMOVE, SSCAN
|
| Sorted sets |
ZADD, ZRANGE, ZREVRANGE, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZRANGEBYLEX, ZREMRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYLEX, ZSCORE, ZMSCORE, ZRANK, ZREVRANK, ZREM, ZCARD, ZCOUNT, ZLEXCOUNT, ZINCRBY, ZPOPMIN, ZPOPMAX, BZPOPMIN, BZPOPMAX, ZINTERSTORE, ZUNIONSTORE, ZUNION, ZDIFF, ZSCAN
|
| HyperLogLog |
PFADD, PFCOUNT, PFMERGE
|
| Geo |
GEOADD, GEOPOS, GEODIST, GEOHASH, GEOSEARCH, GEOSEARCHSTORE, GEORADIUS, GEORADIUS_RO, GEORADIUSBYMEMBER, GEORADIUSBYMEMBER_RO
|
| Streams |
XADD, XREAD, XLEN, XRANGE, XREVRANGE, XINFO, XGROUP, XREADGROUP, XACK, XPENDING, XCLAIM, XAUTOCLAIM, XTRIM, XDEL, XSETID
|
| Pub/Sub |
SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB
|
| Transactions |
MULTI, EXEC, DISCARD, WATCH, UNWATCH
|
| Scripting |
EVAL, EVAL_RO, EVALSHA, EVALSHA_RO, SCRIPT
|
| Server |
FLUSHDB, FLUSHALL, TIME, LASTSAVE, REPLCONF, BGSAVE, BGREWRITEAOF, DEBUG, MEMORY, OBJECT, SLOWLOG, plus SYNC/PSYNC in the connection loop |
| JSON |
JSON.SET, JSON.GET, JSON.MGET, JSON.DEL, JSON.FORGET, JSON.TYPE
|
| Query engine |
FT.CREATE, FT.SEARCH, FT.INFO, FT.DROPINDEX, FT.DROP, FT._LIST
|
(source: src/protocol/redis/commands.rs, execute_inner; src/protocol/redis/commands/geo.rs, geo_command; src/protocol/redis/mod.rs, handle_connection)
Subcommands
| Command | Subcommands handled | Notes |
|---|---|---|
CLIENT |
SETNAME, GETNAME, SETINFO LIB-NAME/LIB-VER, INFO, LIST, ID, GETREDIR (always -1), NO-EVICT, NO-TOUCH, REPLY, UNPAUSE (accepted, no effect) |
CLIENT LIST and CLIENT INFO describe only the calling connection, with a fixed address 127.0.0.1:0. |
CONFIG |
GET (fixed table of about 30 keys, * and prefix* patterns), SET, RESETSTAT, REWRITE
|
SET, RESETSTAT and REWRITE answer +OK and change nothing. |
INFO |
any section | Returns one fixed text (redis_version:7.4.0, connected_clients:1, used_memory:1000000, db0:keys=0,...). Sections are ignored and the figures are not live. |
COMMAND |
any | Always an empty array. |
SCRIPT |
LOAD, EXISTS, FLUSH
|
SCRIPT KILL is not handled. |
PUBSUB |
CHANNELS, NUMSUB, NUMPAT
|
|
XINFO |
STREAM, GROUPS, CONSUMERS
|
|
XGROUP |
CREATE, DESTROY, SETID, DELCONSUMER
|
|
OBJECT |
ENCODING, REFCOUNT (1), IDLETIME (0), FREQ (0) |
ENCODING imitates Redis names (int, embstr, raw, quicklist, hashtable, skiplist). |
MEMORY |
USAGE (always 1024), DOCTOR, STATS (fixed numbers) |
|
DEBUG |
SLEEP <s>; anything else answers +OK
|
|
SLOWLOG |
GET, LEN, RESET
|
|
BGSAVE, BGREWRITEAOF
|
Reply with Redis's status text and do nothing; persistence is continuous. |
(source: src/protocol/redis/commands.rs, client, config, info, command_info, script, pubsub, xinfo, xgroup, object, memory, debug, slowlog, bgsave, bgrewriteaof)
Not implemented
These names appear nowhere in the dispatch match and answer ERR unknown command: FCALL, FCALL_RO, FUNCTION, SWAPDB, MOVE, RANDOMKEY, TOUCH, SORT, SORT_RO, WAIT, WAITAOF, LMPOP, BLMPOP, ZMPOP, BZMPOP, ZRANGESTORE, ZINTER, ZINTERCARD, ZDIFFSTORE, ZRANDMEMBER, SINTERSTORE, SUNIONSTORE, SDIFFSTORE, BITFIELD, BITFIELD_RO, HEXPIRE and the other hash-field TTL commands, SSUBSCRIBE, SUNSUBSCRIBE, SPUBLISH, MONITOR, SHUTDOWN, SAVE, ROLE, CLUSTER, READONLY, READWRITE, LATENCY, MIGRATE, OBJECT HELP. Several of them (FCALL, SWAPDB, SINTERSTORE, ZRANGESTORE, LMPOP and others) are listed in the write-classification helpers is_write_command and mutated_keys, but no handler exists. (source: src/protocol/redis/commands.rs, execute_inner, is_write_command, mutated_keys)
JSON: only the six JSON.* commands above. JSON.ARRAPPEND, JSON.NUMINCRBY, JSON.OBJKEYS, JSON.STRLEN and the rest of RedisJSON are not handled. (source: src/protocol/redis/commands.rs, execute_inner; src/protocol/redis/commands/json.rs, module comment)
FT: FT.AGGREGATE, FT.ALTER, FT.EXPLAIN, FT.PROFILE, FT.SUGADD and the other RediSearch commands are not handled. In FT.SEARCH, FILTER, GEOFILTER, INKEYS, INFIELDS, SUMMARIZE, HIGHLIGHT, DIALECT, TIMEOUT, SLOP, LANGUAGE, EXPANDER, SCORER and PAYLOAD are parsed and skipped. (source: src/protocol/redis/commands/search.rs, the FT.SEARCH option parser)
Data types and storage mapping
In memory
RedisShared holds REDIS_NUM_DBS = 16 databases (SELECT 0..15; out of range answers ERR DB index is out of range). Each RedisDb has a value map, a TTL map, a stream map and blocking-wait notifiers. Values are DataValue: (source: src/protocol/redis/commands/persist.rs, REDIS_NUM_DBS, RedisShared; src/protocol/redis/commands.rs, DataValue, select)
| Redis type |
DataValue variant |
Notes |
|---|---|---|
| string | String(Vec<u8>) |
Bitmaps operate on this. |
| list | List(VecDeque<Vec<u8>>) |
O(1) push and pop at both ends. |
| set | Set(HashSet<Vec<u8>>) |
|
| hash | Hash(HashMap<String, Vec<u8>>) |
Field names are strings. |
| sorted set | SortedSet(Vec<(f64, Vec<u8>)>) |
Geo sets are sorted sets whose scores are 52-bit interleaved geohashes, following Redis's geohash.c. |
| stream |
Stream(Vec<StreamEntry>) in the value map, plus StreamData (entries, consumer groups, last_id) in the stream map |
Entries keep XADD field order. |
| JSON | Json(String) |
Compact JSON text; member order kept; numbers re-serialized as Redis prints them. |
| HyperLogLog | Set |
PFADD inserts members into an exact set, so PFCOUNT is an exact count and TYPE reports set, where Redis reports string and an estimate. Not verified against Redis output beyond the two hll probes of the feature matrix. |
(source: src/protocol/redis/commands.rs, DataValue, StreamData, pfadd; src/protocol/redis/commands/geo.rs, module comment; src/protocol/redis/commands/json.rs, module comment)
JSON paths support $, ., $.a.b, $["a"], $.a[0], $.a[*], $.a.* and the legacy .a.b and bare a forms; legacy paths return one value instead of an array. Filters (?()) and recursive descent (..) are not parsed. (source: src/protocol/redis/commands/json.rs, parse_path)
Expiry
TTLs are absolute wall-clock milliseconds. Expired keys are removed only when a command touches them (check_expiration, "lazy expiration"). There is no background sweep, so an expired key that is never read stays in memory and in storage. (source: src/protocol/redis/commands.rs, check_expiration) Tested by test_expire_and_ttl, test_pexpire_and_pttl and test_expireat_in_the_past_deletes_the_key.
On disk
Everything goes to the shared WAL'd StorageEngine; there is no RDB or AOF file. (source: src/protocol/redis/commands/persist.rs, module comment)
| Storage key | Holds |
|---|---|
__redis__:<key> |
Value record for database 0 (the original layout, kept so old data loads). |
__redisdb__:<NN>:<key> |
Value record for database NN (two digits). |
__redisxs__:<NN>:<key> |
Stream record (StreamRecord { stream, gen }). |
__redisop__:<gen hex16><seq hex16> |
Op record: one logged command (OpRecord { db, key, stream, gen, cmd }). |
__redisacl__:<name> |
ACL user. |
__redisft__: prefix |
Persisted FT.CREATE index definitions. |
Value records are bincode ValueRecordV2 { value, expire_at_ms, gen }; the older RedisPersistRecord { value, expire_at_ms } still decodes. (source: src/protocol/redis/commands/persist.rs, value_storage_key, stream_storage_key, op_storage_key, ValueRecordV2, decode_value_record; src/protocol/redis/commands.rs, REDIS_KEY_PREFIX; src/protocol/redis/commands/search.rs, FT_DEF_PREFIX)
How a write is persisted (persist_command):
- An error reply, or a
0reply from a command inNOOP_ON_ZERO(SADD,DEL,EXPIREand others), writes nothing. - Strings are written whole.
- A single-key collection write from
OP_LOG_COMMANDS(list pushes and pops,LSET,LREM,LTRIM,LINSERT,HSET,HMSET,HSETNX,HDEL,HINCRBY,HINCRBYFLOAT,SADD,SREM,ZADD,ZREM,ZINCRBY,ZPOPMIN,ZPOPMAX,ZREMRANGEBY*) appends the command itself as an op record under the key's generation, so a push onto a long list costs a few bytes. -
XADDis logged with the id the server assigned.LMOVEandRPOPLPUSHare logged as a pop plus a push. - Everything else re-snapshots the touched keys.
- A collection is re-snapshotted (new generation, old ops deleted) when its ops outgrow
max(snapshot size, 256 KiB)or 20,000 ops; collections under 4 KiB are always simply re-snapshotted.
(source: src/protocol/redis/commands/persist.rs, persist_command, append_op, snapshot_value, NOOP_ON_ZERO, OP_LOG_COMMANDS, SMALL_SNAPSHOT_BYTES, MIN_OP_BYTES_BEFORE_COMPACT, MAX_OPS_PER_GEN)
Durability. A write waits for DurabilitySyncer::wait before its reply. With fsync on, connections register with one redis-fsync thread that runs one group_sync for every waiter registered since the last one (group commit). With wal_sync_mode = no_sync, the sync runs inline and only hands buffered records to the OS. If persisting fails (for example a cluster follower refusing the write), the reply becomes an error and the keys are reloaded from storage. (source: src/protocol/redis/commands/persist.rs, DurabilitySyncer; src/protocol/redis/commands.rs, persist_failed)
Startup. load_redis_shared loads snapshots, TTLs and streams, replays op records in order, then compacts. (source: src/protocol/redis/commands/persist.rs, load_redis_shared) Tested by startup_load_restores_every_record_kind in tests/protocol_redis.rs (module keyspace_load) and the persistence_tests module there (test_data_survives_restart, test_del_persists_across_restart, test_overwrite_persists).
DUMP / RESTORE / SYNC. rdb.rs writes RDB version 9 with the plain encodings (string, list, set, hash, zset2) and reads RDB up to version 12, including ziplist, listpack, quicklist, intset, LZF and integer-encoded strings. Streams and modules are not carried by DUMP, RESTORE or SYNC. (source: src/protocol/redis/commands/rdb.rs, RDB_WRITE_VERSION, RDB_MAX_READ_VERSION, module comment) Tested by 5 unit tests in src/protocol/redis/commands/rdb.rs.
Lua scripting
- The VM is Lua 5.1 from
mlua0.9 (featureslua51,vendored), created per call with only thetable,stringandmathstandard libraries;os,io,packageanddebugare not loaded, anddofileandloadfileare removed. (source:Cargo.toml;src/protocol/redis/commands.rs,run_lua;src/protocol/redis/scripting.rs,install_base_env) - Globals:
KEYS,ARGV;redis(alsoserver) withcall,pcall,error_reply,status_reply,sha1hex,log(no-op), theLOG_*andREPL_*constants,REDIS_VERSION = "7.4.0", and no-opreplicate_commands,set_repl,setresp; pluscjson,cmsgpack,bitandstructimplemented in Rust. (source:src/protocol/redis/scripting.rs,install_base_env;src/protocol/redis/lua_libs.rs,install) -
redis.callruns the command through the sameexecutepath, so the auth state and the ACL check apply. Blocking commands answer at once inside a script. - Limits:
SYNERGYDB_REDIS_LUA_TIME_LIMIT_MS(default 5000) stops the script with an error, checked every 100,000 instructions;SYNERGYDB_REDIS_LUA_MEMORY_MB(default 256) caps VM memory. A value of 0 turns the limit off. (source:src/protocol/redis/commands.rs,run_lua) - The script cache (
SCRIPT LOAD,EVAL) is one process-wide map from lowercase SHA-1 to source; it is not persisted.EVALSHAof an unknown digest answersNOSCRIPT No matching script. Please use EVAL.(source:src/protocol/redis/scripting.rs,script_cache,cache_script;src/protocol/redis/commands.rs,eval) -
EVAL_ROandEVALSHA_ROrun the same code path asEVALandEVALSHA. Not verified: nothing inevalrefuses a write from a_ROscript.
Tested by 3 unit tests in src/protocol/redis/scripting.rs and 4 in src/protocol/redis/lua_libs.rs.
Query engine (FT) and vectors
FT.CREATE ... ON HASH|JSON PREFIX ... SCHEMA accepts TEXT, TAG, NUMERIC, GEO and VECTOR fields. Vector fields take FLAT or HNSW with TYPE (FLOAT32, FLOAT64, FLOAT16, BFLOAT16, INT8, UINT8), DIM and DISTANCE_METRIC (L2, IP, COSINE). FT.SEARCH supports TAG, NUMERIC and TEXT filters, KNN and VECTOR_RANGE, PARAMS, RETURN, SORTBY, LIMIT, NOCONTENT and WITHSCORES. (source: src/protocol/redis/commands/search.rs)
- Search is exact brute force over the index's documents. HNSW parameters are accepted and reported in
FT.INFObut do not change the search. Distances follow Redis's formulas (L2 is squared Euclidean, IP is1 - dot, COSINE is1 - dotof normalized vectors) and scores are printed with%.12g. A document with a wrong-size vector or a non-numeric numeric field is not indexed and counts as an indexing failure.FLUSHDBandFLUSHALLdrop every index. (source:src/protocol/redis/commands/search.rs, module comment) - Each vector attribute is mirrored into the process-wide vector service (
storage.vectors()) as databaseredis/<db>, collection<index>/<attribute>, so other wires can search Redis vectors.FT.SEARCHon a name that is not a Redis index searches a cross-wire collection of that name;VECTOR_RANGEis refused there withSEARCH_QUERY_BAD. (source:src/protocol/redis/commands/search.rs,mirror_create,xwire_def,xwire_index)
Tested by 3 unit tests in src/protocol/redis/commands/search.rs and 2 in json.rs; the FT/JSON vector differential is reported as 905/905 against Redis 8 (source: README.md, Wire scorecard).
Error replies
| Reply | When |
|---|---|
NOAUTH Authentication required. |
Any command but AUTH/HELLO/QUIT/RESET before login; also SYNC/PSYNC. |
WRONGPASS invalid username-password pair or user is disabled. |
Failed AUTH. |
NOPERM ... |
ACL refusal. |
NOPROTO unsupported protocol version |
HELLO with a version other than 2 or 3. |
WRONGTYPE Operation against a key holding the wrong kind of value |
Type mismatch (exact Redis text, WRONGTYPE_MSG). |
READONLY You can't write against a read only replica. Leader is <id>. |
Write on a cluster replica. |
EXECABORT Transaction discarded because of: ... |
Refused EXEC. |
NOSCRIPT No matching script. Please use EVAL. |
EVALSHA miss. |
ERR unknown command '<NAME>' |
Not in dispatch. |
ERR <message> |
Any internal Err from a handler, or a parse error. |
SEARCH_SYNTAX ..., SEARCH_PARSE_ARGS ..., SEARCH_QUERY_BAD ...
|
FT.* errors. |
DENIED SynergyDB is running in protected mode ... |
Dev opt-in on and a non-loopback client. |
(source: src/protocol/redis/commands.rs; src/protocol/redis/commands/search.rs; src/auth/wire_auth.rs)
Limits and configuration
| Setting | Default | Effect |
|---|---|---|
redis_port (config) |
6379 | Port; a missing key in a config file turns the wire off. |
Inline line length (max_query_length) |
16 MiB |
ERR_INLINE_TOO_LONG. |
Array elements (max_parameters) |
65,535 |
ERR_MULTIBULK_TOO_LARGE. |
One bulk string (max_string_length) |
1 MiB |
ERR_BULK_TOO_LARGE. |
Whole request (max_message_size) |
256 MiB |
ERR_BULK_TOO_LARGE. |
SYNERGYDB_REDIS_REQUIREPASS |
unset | Single password for user default; when set, catalog roles cannot log in on Redis. |
SYNERGYDB_DEV_INSECURE_AUTH |
unset |
1/true: connections start logged in (test harnesses only). |
SYNERGYDB_TEST_AUTH_CHEAP |
unset |
1/true: AUTH accepts any credentials (test harnesses only). |
SYNERGYDB_WIRE_ACCESS |
enforced |
open/off/any drops the synergy_wire_redis membership check. |
[server] protected_mode / SYNERGYDB_SERVER_PROTECTED_MODE
|
on | See Protected mode. |
SYNERGYDB_REDIS_LUA_TIME_LIMIT_MS |
5000 | Script time limit. |
SYNERGYDB_REDIS_LUA_MEMORY_MB |
256 | Script memory limit. |
The handler uses BufferLimits::default() and there is no config key to change it, so the 1 MiB bulk-string limit applies to every value sent over this wire (stock Redis allows 512 MB; CONFIG GET proto-max-bulk-len reports 536870912). (source: src/protocol/buffer_limits.rs, DEFAULT_MAX_*; src/protocol/redis/mod.rs, RedisHandler::new, RedisHandler::with_storage, read_command; src/protocol/redis/commands.rs, config) Not verified: no test sends a bulk string over 1 MiB.
Test coverage
| Where | What |
|---|---|
tests/protocol_redis.rs (177 tests) |
Modules string_commands, list_commands, hash_commands, set_commands, sorted_set_commands, key_commands, server_commands, transaction_commands, persistence_tests, error_handling, keyspace_load. They drive CommandExecutor directly, logged in with a test requirepass (tests/protocol_helpers/mod.rs, authenticate_redis), not over a socket. |
src/protocol/redis/** unit tests |
resp.rs 18, commands.rs 15 (auth gate, expiry bounds, pub/sub registry), acl.rs 8, rdb.rs 5, lua_libs.rs 4, scripting.rs 3, search.rs 3, json.rs 2, geo.rs 2, mod.rs 1. |
| Proof logs |
redis-command-corpus.txt (110/110 vs Redis 7), redis-live-suite-second-connection-blocking-ops-restart.txt (57/57), redis-feature-matrix.txt (50/51; the divergence is scan/scan-cursor). |
(source: the files named; docs/proof/2026-11-30/proof-pack-a3232c9/logs/)
tests/protocol_coverage.rs (runtime_probe_redis) sends each name of a Redis 7 command list to a fresh CommandExecutor and counts every reply other than ERR unknown command as recognized. Because that executor is not logged in, every probe answers NOAUTH, so the probe counts every name as recognized and does not measure dispatch. (source: tests/protocol_coverage.rs, runtime_probe_redis)
Lua appears in Rust tests only through the ACL test acl_script_refusal_matches_redis_text, and pub/sub only through test_shared_registry_publish_reaches_subscriber (executor level). No Rust test covers stream consumer groups, FT.* beyond the unit tests, RESP3 reshaping, SYNC/PSYNC, TLS, or the isolation gate. Those are covered only by the Python differential suites behind the proof logs.