Command reference

Command reference #

Every command the engine registers, grouped by data type. The table below is the whole surface: 110 commands, plus the system commands (RAFT, CLUSTER, MACHINE, BARRIER, AUTH, …) that the Raft/RESP layer answers.

PageCommandsCount
StringsSET … BITPOS, expiry26
HashesHSET … HMCLEAR, expiry19
ListsLPUSH … LREM, expiry18
SetsSADD … SPERSIST21
Sorted setsZADD … ZCLEAR15
ScanSCAN/HSCAN/SSCAN/ZSCAN + the X* family8
ServerINFO, FLUSHALL, FLUSHDB3
Compatibilitydivergences from Redis, with reasons—

Notation #

NotationMeaning
KEYBinary-safe key name, up to 1024 bytes (ledis MaxKeySize; empty keys are rejected)
VALUEBinary-safe value, up to 1 GiB (MaxValueSize)
[ARG]Optional argument
ARG...One or more repetitions
A | BAlternative
R / WRead command (runs locally) / write command (replicated through the Raft log)
integerRESP integer :1
bulkRESP bulk string $3 foo
nullRESP null bulk $-1, “no such value”
arrayRESP array *2 …
+OKRESP simple string

Rules that apply to every command #

  1. One keyspace per data type. A key can hold a string and a hash and a list at the same time. A command for the wrong type operates on that type’s own (possibly empty) view instead of answering WRONGTYPE. See Compatibility.
  2. Expiration is per type. EXPIRE/TTL apply to the string; HEXPIRE/HTTL to the hash; LEXPIRE/LTTL to the list; SEXPIRE/STTL/SPERSIST to the set. Sorted sets have no TTL command. TTLs are whole seconds; -1 means “no expiration” and is also what an expired key reports.
  3. Scores are 64-bit integers, not floats.
  4. Counts and paging are bounded. COUNT is capped at 10000, |count| on SRANDMEMBER at 1048576.
  5. Writes are replayed on every replica, so their result must be identical cluster-wide — that is why e.g. SPOP picks deterministically.
  6. Errors are RESP errors (-ERR …). -WRONGTYPE is never produced. A follower that may not serve a read answers -MOVED (or -TRY with --try-errors).

Read/write classes, and why they matter #

R means the handler is registered with conf.AddReadCommand: it executes on the node that receives it, against whatever state that node has applied. W means conf.AddWriteCommand: it is serialised through the Raft log and applied on every node.

Three sorted-set commands are registered as reads although they mutate:

CommandRegistered asEffect in a cluster
ZINCRBYRMutates the local node only — not replicated, lost on leader change
ZREMRANGEBYRANKRSame
ZREMRANGEBYSCORERSame

Until that changes, use ZADD with a computed score, and delete members with ZREM.

Reply types #

Handlers return Go values that the RESP layer maps directly:

Handler returnsClient sees
nilnull bulk ($-1)
[]bytebulk string
[][]byte, []stringarray
redcon.SimpleStringsimple string (+OK)
redcon.SimpleInt, int64integer
errorerror reply (-ERR …)

A simple string cannot carry \r\n, so values are never returned as one.

Limits #

LimitValue
Key size1024 bytes (ledis.MaxKeySize); an empty key is rejected
Hash field / set member / zset member1024 bytes each
Value size1 GiB (ledis.MaxValueSize)
COUNT on any scan10000, clamped; still only a hint
SRANDMEMBER / SPOP countabsolute value ≤ 1048576; SPOP clamps to set size
Expirationwhole seconds; PX rounds up; unrepresentable EX is refused
Databases1 (SELECT unimplemented)
Blocking commandsnone (BLPOP/BRPOP are not registered)