Skip to main content

Route

Enum Route 

Source
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

MSETargs[1..] are key/value pairs, routed per key’s shard.

§

MGet

MGETargs[1..] are keys; values gathered in request order.

§

SInter

SINTER / SUNION / SDIFFargs[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).

Fields

§nx: bool

true for RENAMENX (no overwrite — reply :0 if dst exists).

§

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).

Fields

§streams: Vec<(Vec<u8>, Vec<u8>)>
§count: Option<usize>

Trait Implementations§

Source§

impl Debug for Route

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Route

§

impl RefUnwindSafe for Route

§

impl Send for Route

§

impl Sync for Route

§

impl Unpin for Route

§

impl UnsafeUnpin for Route

§

impl UnwindSafe for Route

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.