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.
Set
SET key value [EX seconds | PX milliseconds] [NX | XX].
Fields
Incr
INCR key. Increments the integer value of a key by 1.
Decr
DECR key. Decrements the integer value of a key by 1.
IncrBy
INCRBY key increment. Increments the integer value of a key by the given amount.
DecrBy
DECRBY key decrement. Decrements the integer value of a key by the given amount.
IncrByFloat
INCRBYFLOAT key increment. Increments the float value of a key by the given amount.
Append
APPEND key value. Appends a value to a string key. Returns the new length.
Strlen
STRLEN key. Returns the length of the string value stored at key.
Keys
KEYS pattern. Returns all keys matching a glob pattern.
Rename
RENAME key newkey. Renames a key.
Del
DEL key [key …]. Returns the number of keys removed.
Unlink
UNLINK key [key …]. Like DEL but frees memory in the background.
Exists
EXISTS key [key …]. Returns the number of keys that exist.
MGet
MGET key [key …]. Returns the values for all specified keys.
MSet
MSET key value [key value …]. Sets multiple key-value pairs.
Expire
EXPIRE key seconds. Sets a TTL on an existing key.
Ttl
TTL key. Returns remaining time-to-live in seconds.
Persist
PERSIST key. Removes the expiration from a key.
Pttl
PTTL key. Returns remaining time-to-live in milliseconds.
Pexpire
PEXPIRE key milliseconds. Sets a TTL in milliseconds on an existing key.
DbSize
DBSIZE. Returns the number of keys in the database.
Info
INFO [section]. Returns server info. Currently only supports “keyspace”.
BgSave
BGSAVE. Triggers a background snapshot.
BgRewriteAof
BGREWRITEAOF. Triggers an AOF rewrite (snapshot + truncate).
FlushDb
FLUSHDB [ASYNC]. Removes all keys from the database.
Scan
SCAN cursor [MATCH pattern] [COUNT count]. Iterates keys.
LPush
LPUSH key value [value …]. Pushes values to the head of a list.
RPush
RPUSH key value [value …]. Pushes values to the tail of a list.
LPop
LPOP key. Pops a value from the head of a list.
RPop
RPOP key. Pops a value from the tail of a list.
LRange
LRANGE key start stop. Returns a range of elements by index.
LLen
LLEN key. Returns the length of a list.
Type
TYPE key. Returns the type of the value stored at key.
ZAdd
ZADD key [NX|XX] [GT|LT] [CH] score member [score member …].
ZRem
ZREM key member [member …]. Removes members from a sorted set.
ZScore
ZSCORE key member. Returns the score of a member.
ZRank
ZRANK key member. Returns the rank of a member (0-based).
ZCard
ZCARD key. Returns the cardinality (number of members) of a sorted set.
ZRange
ZRANGE key start stop [WITHSCORES]. Returns a range by rank.
HSet
HSET key field value [field value …]. Sets field-value pairs in a hash.
HGet
HGET key field. Gets a field’s value from a hash.
HGetAll
HGETALL key. Gets all field-value pairs from a hash.
HDel
HDEL key field [field …]. Deletes fields from a hash.
HExists
HEXISTS key field. Checks if a field exists in a hash.
HLen
HLEN key. Returns the number of fields in a hash.
HIncrBy
HINCRBY key field increment. Increments a hash field’s integer value.
HKeys
HKEYS key. Returns all field names in a hash.
HVals
HVALS key. Returns all values in a hash.
HMGet
HMGET key field [field …]. Gets multiple field values from a hash.
SAdd
SADD key member [member …]. Adds members to a set.
SRem
SREM key member [member …]. Removes members from a set.
SMembers
SMEMBERS key. Returns all members of a set.
SIsMember
SISMEMBER key member. Checks if a member exists in a set.
SCard
SCARD key. Returns the cardinality (number of members) of a set.
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.
ClusterMyId
CLUSTER MYID. Returns the node’s ID.
ClusterSetSlotImporting
CLUSTER SETSLOT slot IMPORTING node-id. Mark slot as importing from node.
ClusterSetSlotMigrating
CLUSTER SETSLOT slot MIGRATING node-id. Mark slot as migrating to node.
ClusterSetSlotNode
CLUSTER SETSLOT slot NODE node-id. Assign slot to node.
ClusterSetSlotStable
CLUSTER SETSLOT slot STABLE. Clear importing/migrating state.
ClusterMeet
CLUSTER MEET ip port. Add a node to the cluster.
ClusterAddSlots
CLUSTER ADDSLOTS slot [slot…]. Assign slots to the local node.
ClusterDelSlots
CLUSTER DELSLOTS slot [slot…]. Remove slots from the local node.
ClusterForget
CLUSTER FORGET node-id. Remove a node from the cluster.
ClusterReplicate
CLUSTER REPLICATE node-id. Make this node a replica of another.
ClusterFailover
CLUSTER FAILOVER [FORCE|TAKEOVER]. Trigger a manual failover.
ClusterCountKeysInSlot
CLUSTER COUNTKEYSINSLOT slot. Return the number of keys in a slot.
ClusterGetKeysInSlot
CLUSTER GETKEYSINSLOT slot count. Return keys in a slot.
Migrate
MIGRATE host port key db timeout [COPY] [REPLACE] [KEYS key…].
Migrate a key to another node.
Asking
ASKING. Signals that the next command is for a migrating slot.
SlowLogGet
SLOWLOG GET [count]. Returns recent slow log entries.
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.
Unsubscribe
UNSUBSCRIBE [channel …]. Unsubscribe from channels (all if none given).
PSubscribe
PSUBSCRIBE pattern [pattern …]. Subscribe to channels matching patterns.
PUnsubscribe
PUNSUBSCRIBE [pattern …]. Unsubscribe from patterns (all if none given).
Publish
PUBLISH channel message. Publish a message to a channel.
PubSubChannels
PUBSUB CHANNELS [pattern]. List active channels, optionally matching a glob.
PubSubNumSub
PUBSUB NUMSUB [channel …]. Returns subscriber counts for given channels.
PubSubNumPat
PUBSUB NUMPAT. Returns the number of active pattern subscriptions.
Auth
AUTH [username] password. Authenticate the connection.
Fields
Quit
QUIT. Requests the server to close the connection.
Unknown(String)
A command we don’t recognize (yet).
Implementations§
Source§impl Command
impl Command
Sourcepub fn command_name(&self) -> &'static str
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.