pub enum Route {
Show 28 variants
Local,
Single(usize),
DelKeys,
ExistsKeys,
Dbsize,
Flush,
Save,
BgSave,
RewriteAof,
MSet,
MGet,
SInter,
SUnion,
SDiff,
Keys(Option<Vec<u8>>),
Scan(Option<Vec<u8>>),
RandomKey,
Subscribe,
Unsubscribe,
Psubscribe,
Punsubscribe,
Publish,
Watch,
Unwatch,
Hello,
Rename {
nx: bool,
},
Slowlog(SlowlogSub),
XReadGather {
streams: Vec<(Vec<u8>, Vec<u8>)>,
count: Option<usize>,
group: Option<XGroupCtx>,
},
}Expand description
How a command maps onto shards.
Variants§
Local
Keyless; execute on the connection’s own shard (e.g. PING).
Single(usize)
Single-key; route by args[idx].
DelKeys
args[1..] are keys; delete each on its shard, sum the counts.
ExistsKeys
args[1..] are keys; count existing across shards.
Dbsize
Sum every shard’s key count.
Flush
Flush every shard.
Save
Snapshot every shard’s store to disk, synchronously (SAVE —
blocks until durable, the Redis contract for the explicit form).
BgSave
BGSAVE — collect a COW view per shard and persist in the
background; the command returns once the views are frozen.
RewriteAof
BGREWRITEAOF — rebuild every shard’s AOF from in-memory state.
Synchronous in v1.0 (each shard blocks for its own rewrite duration).
MSet
MSET — args[1..] are key/value pairs, routed per key’s shard.
MGet
MGET — args[1..] are keys; values gathered in request order.
SInter
SINTER / SUNION / SDIFF — args[1..] are set keys.
SUnion
SDiff
Keys(Option<Vec<u8>>)
KEYS pattern — every shard returns its matching keys.
Scan(Option<Vec<u8>>)
SCAN (cursor-0 approximation) — like KEYS but replies [cursor, keys].
RandomKey
RANDOMKEY — one arbitrary key across all shards.
Subscribe
SUBSCRIBE / UNSUBSCRIBE — connection-level (modifies this conn).
Unsubscribe
Psubscribe
PSUBSCRIBE pattern [pattern ...] / PUNSUBSCRIBE [pattern ...] —
like Subscribe/Unsubscribe but the conn registers Redis-glob
patterns; PUBLISH to a matching channel delivers a pmessage
frame. Connection-level (modifies this conn + shared pattern
registry).
Punsubscribe
Publish
PUBLISH channel message — delivered to subscribers on every core.
Watch
WATCH key [key ...] — fan-out to record per-shard versions, then
stash the (key, version) pairs in the conn’s watched set so the
next EXEC can validate them. Connection-level.
Unwatch
UNWATCH — clear the conn’s watched set. Connection-level, local.
Hello
HELLO [protover [AUTH user pass] [SETNAME name]] — server
handshake; on HELLO 3 flips the conn into RESP3 mode (per-conn
proto field). Reply shape itself is proto-aware (V2: array of
pairs; V3: Map). Connection-level, dispatch via the
crate::Commands::hello_reply hook so embedders set their own server
metadata.
Rename
RENAME source destination / RENAMENX source destination. The
runtime handles the two-shard decision: same-shard renames go
through one atomic crate::Store::rename on the owning shard; cross-
shard renames use the Take→Put orchestrator (lands in v2-3b;
v2-3a emits -CROSSSHARD ... for that case).
Slowlog(SlowlogSub)
SLOWLOG GET / LEN / RESET / HELP. The sub-command + parsed
args are pre-decoded at routing time so the runtime knows
whether to short-circuit (HELP / error) or fan out across
shards (GET / LEN / RESET). See crate::parse_slowlog_sub.
XReadGather
Non-blocking XREAD / XREADGROUP over multiple streams — fan
each stream out to its owning shard and merge the per-stream replies
in request order (single-stream forms still route via
Self::Single). Each element is (stream key, last-seen id);
count is the optional COUNT cap applied per stream; group
Some makes each per-shard sub-query an XREADGROUP (a write —
PEL / last-delivered updates happen on each stream’s owning shard
and are AOF-logged there as the rewritten single-stream command).
The command set builds this only for the non-blocking, ≥2-stream
forms; blocking reads park on the origin shard instead (see the
cross-shard BLOCK arbiter).