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.
| Page | Commands | Count |
|---|---|---|
| Strings | SET … BITPOS, expiry | 26 |
| Hashes | HSET … HMCLEAR, expiry | 19 |
| Lists | LPUSH … LREM, expiry | 18 |
| Sets | SADD … SPERSIST | 21 |
| Sorted sets | ZADD … ZCLEAR | 15 |
| Scan | SCAN/HSCAN/SSCAN/ZSCAN + the X* family | 8 |
| Server | INFO, FLUSHALL, FLUSHDB | 3 |
| Compatibility | divergences from Redis, with reasons | — |
Notation #
| Notation | Meaning |
|---|---|
KEY | Binary-safe key name, up to 1024 bytes (ledis MaxKeySize; empty keys are rejected) |
VALUE | Binary-safe value, up to 1 GiB (MaxValueSize) |
[ARG] | Optional argument |
ARG... | One or more repetitions |
A | B | Alternative |
| R / W | Read command (runs locally) / write command (replicated through the Raft log) |
integer | RESP integer :1 |
bulk | RESP bulk string $3 foo |
null | RESP null bulk $-1, “no such value” |
array | RESP array *2 … |
+OK | RESP simple string |
Rules that apply to every command #
- 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. - Expiration is per type.
EXPIRE/TTLapply to the string;HEXPIRE/HTTLto the hash;LEXPIRE/LTTLto the list;SEXPIRE/STTL/SPERSISTto the set. Sorted sets have no TTL command. TTLs are whole seconds;-1means “no expiration” and is also what an expired key reports. - Scores are 64-bit integers, not floats.
- Counts and paging are bounded.
COUNTis capped at 10000,|count|onSRANDMEMBERat 1048576. - Writes are replayed on every replica, so their result must be identical cluster-wide — that is
why e.g.
SPOPpicks deterministically. - Errors are RESP errors (
-ERR …).-WRONGTYPEis never produced. A follower that may not serve a read answers-MOVED(or-TRYwith--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:
| Command | Registered as | Effect in a cluster |
|---|---|---|
ZINCRBY | R | Mutates the local node only — not replicated, lost on leader change |
ZREMRANGEBYRANK | R | Same |
ZREMRANGEBYSCORE | R | Same |
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 returns | Client sees |
|---|---|
nil | null bulk ($-1) |
[]byte | bulk string |
[][]byte, []string | array |
redcon.SimpleString | simple string (+OK) |
redcon.SimpleInt, int64 | integer |
error | error reply (-ERR …) |
A simple string cannot carry \r\n, so values are never returned as one.
Limits #
| Limit | Value |
|---|---|
| Key size | 1024 bytes (ledis.MaxKeySize); an empty key is rejected |
| Hash field / set member / zset member | 1024 bytes each |
| Value size | 1 GiB (ledis.MaxValueSize) |
COUNT on any scan | 10000, clamped; still only a hint |
SRANDMEMBER / SPOP count | absolute value ≤ 1048576; SPOP clamps to set size |
| Expiration | whole seconds; PX rounds up; unrepresentable EX is refused |
| Databases | 1 (SELECT unimplemented) |
| Blocking commands | none (BLPOP/BRPOP are not registered) |