Skip to main content

Command

Enum Command 

Source
pub enum Command {
Show 90 variants Ping(Option<Bytes>), Echo(Bytes), Get { key: String, }, Set { key: String, value: Bytes, expire: Option<SetExpire>, nx: bool, xx: bool, }, Incr { key: String, }, Decr { key: String, }, IncrBy { key: String, delta: i64, }, DecrBy { key: String, delta: i64, }, IncrByFloat { key: String, delta: f64, }, Append { key: String, value: Bytes, }, Strlen { key: String, }, Keys { pattern: String, }, Rename { key: String, newkey: String, }, Del { keys: Vec<String>, }, Unlink { keys: Vec<String>, }, Exists { keys: Vec<String>, }, MGet { keys: Vec<String>, }, MSet { pairs: Vec<(String, Bytes)>, }, Expire { key: String, seconds: u64, }, Ttl { key: String, }, Persist { key: String, }, Pttl { key: String, }, Pexpire { key: String, milliseconds: u64, }, DbSize, Info { section: Option<String>, }, BgSave, BgRewriteAof, FlushDb { async_mode: bool, }, Scan { cursor: u64, pattern: Option<String>, count: Option<usize>, }, LPush { key: String, values: Vec<Bytes>, }, RPush { key: String, values: Vec<Bytes>, }, LPop { key: String, }, RPop { key: String, }, LRange { key: String, start: i64, stop: i64, }, LLen { key: String, }, Type { key: String, }, ZAdd { key: String, flags: ZAddFlags, members: Vec<(f64, String)>, }, ZRem { key: String, members: Vec<String>, }, ZScore { key: String, member: String, }, ZRank { key: String, member: String, }, ZCard { key: String, }, ZRange { key: String, start: i64, stop: i64, with_scores: bool, }, HSet { key: String, fields: Vec<(String, Bytes)>, }, HGet { key: String, field: String, }, HGetAll { key: String, }, HDel { key: String, fields: Vec<String>, }, HExists { key: String, field: String, }, HLen { key: String, }, HIncrBy { key: String, field: String, delta: i64, }, HKeys { key: String, }, HVals { key: String, }, HMGet { key: String, fields: Vec<String>, }, SAdd { key: String, members: Vec<String>, }, SRem { key: String, members: Vec<String>, }, SMembers { key: String, }, SIsMember { key: String, member: String, }, SCard { key: String, }, ClusterInfo, ClusterNodes, ClusterSlots, ClusterKeySlot { key: String, }, ClusterMyId, ClusterSetSlotImporting { slot: u16, node_id: String, }, ClusterSetSlotMigrating { slot: u16, node_id: String, }, ClusterSetSlotNode { slot: u16, node_id: String, }, ClusterSetSlotStable { slot: u16, }, ClusterMeet { ip: String, port: u16, }, ClusterAddSlots { slots: Vec<u16>, }, ClusterDelSlots { slots: Vec<u16>, }, ClusterForget { node_id: String, }, ClusterReplicate { node_id: String, }, ClusterFailover { force: bool, takeover: bool, }, ClusterCountKeysInSlot { slot: u16, }, ClusterGetKeysInSlot { slot: u16, count: u32, }, Migrate { host: String, port: u16, key: String, db: u32, timeout_ms: u64, copy: bool, replace: bool, }, Asking, SlowLogGet { count: Option<usize>, }, SlowLogLen, SlowLogReset, Subscribe { channels: Vec<String>, }, Unsubscribe { channels: Vec<String>, }, PSubscribe { patterns: Vec<String>, }, PUnsubscribe { patterns: Vec<String>, }, Publish { channel: String, message: Bytes, }, PubSubChannels { pattern: Option<String>, }, PubSubNumSub { channels: Vec<String>, }, PubSubNumPat, Auth { username: Option<String>, password: String, }, Quit, Unknown(String),
}
Expand description

A parsed client command, ready for execution.

Variants§

§

Ping(Option<Bytes>)

PING with an optional message. Returns PONG or echoes the message.

§

Echo(Bytes)

ECHO message. Returns the message back to the client.

§

Get

GET key. Returns the value or nil.

Fields

§

Set

SET key value [EX seconds | PX milliseconds] [NX | XX].

Fields

§value: Bytes
§nx: bool

Only set the key if it does not already exist.

§xx: bool

Only set the key if it already exists.

§

Incr

INCR key. Increments the integer value of a key by 1.

Fields

§

Decr

DECR key. Decrements the integer value of a key by 1.

Fields

§

IncrBy

INCRBY key increment. Increments the integer value of a key by the given amount.

Fields

§delta: i64
§

DecrBy

DECRBY key decrement. Decrements the integer value of a key by the given amount.

Fields

§delta: i64
§

IncrByFloat

INCRBYFLOAT key increment. Increments the float value of a key by the given amount.

Fields

§delta: f64
§

Append

APPEND key value. Appends a value to a string key. Returns the new length.

Fields

§value: Bytes
§

Strlen

STRLEN key. Returns the length of the string value stored at key.

Fields

§

Keys

KEYS pattern. Returns all keys matching a glob pattern.

Fields

§pattern: String
§

Rename

RENAME key newkey. Renames a key.

Fields

§newkey: String
§

Del

DEL key [key …]. Returns the number of keys removed.

Fields

§keys: Vec<String>

UNLINK key [key …]. Like DEL but frees memory in the background.

Fields

§keys: Vec<String>
§

Exists

EXISTS key [key …]. Returns the number of keys that exist.

Fields

§keys: Vec<String>
§

MGet

MGET key [key …]. Returns the values for all specified keys.

Fields

§keys: Vec<String>
§

MSet

MSET key value [key value …]. Sets multiple key-value pairs.

Fields

§pairs: Vec<(String, Bytes)>
§

Expire

EXPIRE key seconds. Sets a TTL on an existing key.

Fields

§seconds: u64
§

Ttl

TTL key. Returns remaining time-to-live in seconds.

Fields

§

Persist

PERSIST key. Removes the expiration from a key.

Fields

§

Pttl

PTTL key. Returns remaining time-to-live in milliseconds.

Fields

§

Pexpire

PEXPIRE key milliseconds. Sets a TTL in milliseconds on an existing key.

Fields

§milliseconds: u64
§

DbSize

DBSIZE. Returns the number of keys in the database.

§

Info

INFO [section]. Returns server info. Currently only supports “keyspace”.

Fields

§section: Option<String>
§

BgSave

BGSAVE. Triggers a background snapshot.

§

BgRewriteAof

BGREWRITEAOF. Triggers an AOF rewrite (snapshot + truncate).

§

FlushDb

FLUSHDB [ASYNC]. Removes all keys from the database.

Fields

§async_mode: bool
§

Scan

SCAN cursor [MATCH pattern] [COUNT count]. Iterates keys.

Fields

§cursor: u64
§pattern: Option<String>
§count: Option<usize>
§

LPush

LPUSH key value [value …]. Pushes values to the head of a list.

Fields

§values: Vec<Bytes>
§

RPush

RPUSH key value [value …]. Pushes values to the tail of a list.

Fields

§values: Vec<Bytes>
§

LPop

LPOP key. Pops a value from the head of a list.

Fields

§

RPop

RPOP key. Pops a value from the tail of a list.

Fields

§

LRange

LRANGE key start stop. Returns a range of elements by index.

Fields

§start: i64
§stop: i64
§

LLen

LLEN key. Returns the length of a list.

Fields

§

Type

TYPE key. Returns the type of the value stored at key.

Fields

§

ZAdd

ZADD key [NX|XX] [GT|LT] [CH] score member [score member …].

Fields

§members: Vec<(f64, String)>
§

ZRem

ZREM key member [member …]. Removes members from a sorted set.

Fields

§members: Vec<String>
§

ZScore

ZSCORE key member. Returns the score of a member.

Fields

§member: String
§

ZRank

ZRANK key member. Returns the rank of a member (0-based).

Fields

§member: String
§

ZCard

ZCARD key. Returns the cardinality (number of members) of a sorted set.

Fields

§

ZRange

ZRANGE key start stop [WITHSCORES]. Returns a range by rank.

Fields

§start: i64
§stop: i64
§with_scores: bool
§

HSet

HSET key field value [field value …]. Sets field-value pairs in a hash.

Fields

§fields: Vec<(String, Bytes)>
§

HGet

HGET key field. Gets a field’s value from a hash.

Fields

§field: String
§

HGetAll

HGETALL key. Gets all field-value pairs from a hash.

Fields

§

HDel

HDEL key field [field …]. Deletes fields from a hash.

Fields

§fields: Vec<String>
§

HExists

HEXISTS key field. Checks if a field exists in a hash.

Fields

§field: String
§

HLen

HLEN key. Returns the number of fields in a hash.

Fields

§

HIncrBy

HINCRBY key field increment. Increments a hash field’s integer value.

Fields

§field: String
§delta: i64
§

HKeys

HKEYS key. Returns all field names in a hash.

Fields

§

HVals

HVALS key. Returns all values in a hash.

Fields

§

HMGet

HMGET key field [field …]. Gets multiple field values from a hash.

Fields

§fields: Vec<String>
§

SAdd

SADD key member [member …]. Adds members to a set.

Fields

§members: Vec<String>
§

SRem

SREM key member [member …]. Removes members from a set.

Fields

§members: Vec<String>
§

SMembers

SMEMBERS key. Returns all members of a set.

Fields

§

SIsMember

SISMEMBER key member. Checks if a member exists in a set.

Fields

§member: String
§

SCard

SCARD key. Returns the cardinality (number of members) of a set.

Fields

§

ClusterInfo

CLUSTER INFO. Returns cluster state and configuration information.

§

ClusterNodes

CLUSTER NODES. Returns the list of cluster nodes.

§

ClusterSlots

CLUSTER SLOTS. Returns the slot distribution across nodes.

§

ClusterKeySlot

CLUSTER KEYSLOT key. Returns the hash slot for a key.

Fields

§

ClusterMyId

CLUSTER MYID. Returns the node’s ID.

§

ClusterSetSlotImporting

CLUSTER SETSLOT slot IMPORTING node-id. Mark slot as importing from node.

Fields

§slot: u16
§node_id: String
§

ClusterSetSlotMigrating

CLUSTER SETSLOT slot MIGRATING node-id. Mark slot as migrating to node.

Fields

§slot: u16
§node_id: String
§

ClusterSetSlotNode

CLUSTER SETSLOT slot NODE node-id. Assign slot to node.

Fields

§slot: u16
§node_id: String
§

ClusterSetSlotStable

CLUSTER SETSLOT slot STABLE. Clear importing/migrating state.

Fields

§slot: u16
§

ClusterMeet

CLUSTER MEET ip port. Add a node to the cluster.

Fields

§port: u16
§

ClusterAddSlots

CLUSTER ADDSLOTS slot [slot…]. Assign slots to the local node.

Fields

§slots: Vec<u16>
§

ClusterDelSlots

CLUSTER DELSLOTS slot [slot…]. Remove slots from the local node.

Fields

§slots: Vec<u16>
§

ClusterForget

CLUSTER FORGET node-id. Remove a node from the cluster.

Fields

§node_id: String
§

ClusterReplicate

CLUSTER REPLICATE node-id. Make this node a replica of another.

Fields

§node_id: String
§

ClusterFailover

CLUSTER FAILOVER [FORCE|TAKEOVER]. Trigger a manual failover.

Fields

§force: bool
§takeover: bool
§

ClusterCountKeysInSlot

CLUSTER COUNTKEYSINSLOT slot. Return the number of keys in a slot.

Fields

§slot: u16
§

ClusterGetKeysInSlot

CLUSTER GETKEYSINSLOT slot count. Return keys in a slot.

Fields

§slot: u16
§count: u32
§

Migrate

MIGRATE host port key db timeout [COPY] [REPLACE] [KEYS key…]. Migrate a key to another node.

Fields

§host: String
§port: u16
§db: u32
§timeout_ms: u64
§copy: bool
§replace: bool
§

Asking

ASKING. Signals that the next command is for a migrating slot.

§

SlowLogGet

SLOWLOG GET [count]. Returns recent slow log entries.

Fields

§count: Option<usize>
§

SlowLogLen

SLOWLOG LEN. Returns the number of entries in the slow log.

§

SlowLogReset

SLOWLOG RESET. Clears the slow log.

§

Subscribe

SUBSCRIBE channel [channel …]. Subscribe to one or more channels.

Fields

§channels: Vec<String>
§

Unsubscribe

UNSUBSCRIBE [channel …]. Unsubscribe from channels (all if none given).

Fields

§channels: Vec<String>
§

PSubscribe

PSUBSCRIBE pattern [pattern …]. Subscribe to channels matching patterns.

Fields

§patterns: Vec<String>
§

PUnsubscribe

PUNSUBSCRIBE [pattern …]. Unsubscribe from patterns (all if none given).

Fields

§patterns: Vec<String>
§

Publish

PUBLISH channel message. Publish a message to a channel.

Fields

§channel: String
§message: Bytes
§

PubSubChannels

PUBSUB CHANNELS [pattern]. List active channels, optionally matching a glob.

Fields

§pattern: Option<String>
§

PubSubNumSub

PUBSUB NUMSUB [channel …]. Returns subscriber counts for given channels.

Fields

§channels: Vec<String>
§

PubSubNumPat

PUBSUB NUMPAT. Returns the number of active pattern subscriptions.

§

Auth

AUTH [username] password. Authenticate the connection.

Fields

§username: Option<String>

Username for ACL-style auth. None for legacy AUTH.

§password: String

The password to validate.

§

Quit

QUIT. Requests the server to close the connection.

§

Unknown(String)

A command we don’t recognize (yet).

Implementations§

Source§

impl Command

Source

pub fn command_name(&self) -> &'static str

Returns the lowercase command name as a static string.

Used for metrics labels and slow log entries. Zero allocation — returns a &'static str for every known variant.

Source

pub fn from_frame(frame: Frame) -> Result<Command, ProtocolError>

Parses a Frame into a Command.

Expects an array frame where the first element is the command name (as a bulk or simple string) and the rest are arguments.

Trait Implementations§

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Command) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Command

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.