pub enum Command<'a> {
Show 48 variants
Ping,
Get {
key: &'a [u8],
},
Set {
key: &'a [u8],
value: &'a [u8],
ex: Option<u64>,
px: Option<u64>,
nx: bool,
xx: bool,
},
Del {
key: &'a [u8],
},
MGet {
keys: Vec<&'a [u8]>,
},
Config {
subcommand: &'a [u8],
args: Vec<&'a [u8]>,
},
Cluster {
subcommand: &'a [u8],
args: Vec<&'a [u8]>,
},
Asking,
ReadOnly,
ReadWrite,
FlushDb,
FlushAll,
Incr {
key: &'a [u8],
},
Decr {
key: &'a [u8],
},
IncrBy {
key: &'a [u8],
delta: i64,
},
DecrBy {
key: &'a [u8],
delta: i64,
},
Append {
key: &'a [u8],
value: &'a [u8],
},
HSet {
key: &'a [u8],
fields: Vec<(&'a [u8], &'a [u8])>,
},
HGet {
key: &'a [u8],
field: &'a [u8],
},
HMGet {
key: &'a [u8],
fields: Vec<&'a [u8]>,
},
HGetAll {
key: &'a [u8],
},
HDel {
key: &'a [u8],
fields: Vec<&'a [u8]>,
},
HExists {
key: &'a [u8],
field: &'a [u8],
},
HLen {
key: &'a [u8],
},
HKeys {
key: &'a [u8],
},
HVals {
key: &'a [u8],
},
HSetNx {
key: &'a [u8],
field: &'a [u8],
value: &'a [u8],
},
HIncrBy {
key: &'a [u8],
field: &'a [u8],
delta: i64,
},
LPush {
key: &'a [u8],
values: Vec<&'a [u8]>,
},
RPush {
key: &'a [u8],
values: Vec<&'a [u8]>,
},
LPop {
key: &'a [u8],
count: Option<usize>,
},
RPop {
key: &'a [u8],
count: Option<usize>,
},
LRange {
key: &'a [u8],
start: i64,
stop: i64,
},
LLen {
key: &'a [u8],
},
LIndex {
key: &'a [u8],
index: i64,
},
LSet {
key: &'a [u8],
index: i64,
value: &'a [u8],
},
LTrim {
key: &'a [u8],
start: i64,
stop: i64,
},
LPushX {
key: &'a [u8],
values: Vec<&'a [u8]>,
},
RPushX {
key: &'a [u8],
values: Vec<&'a [u8]>,
},
SAdd {
key: &'a [u8],
members: Vec<&'a [u8]>,
},
SRem {
key: &'a [u8],
members: Vec<&'a [u8]>,
},
SMembers {
key: &'a [u8],
},
SIsMember {
key: &'a [u8],
member: &'a [u8],
},
SMisMember {
key: &'a [u8],
members: Vec<&'a [u8]>,
},
SCard {
key: &'a [u8],
},
SPop {
key: &'a [u8],
count: Option<usize>,
},
SRandMember {
key: &'a [u8],
count: Option<i64>,
},
Type {
key: &'a [u8],
},
}Expand description
A parsed Redis command with references to the original buffer.
Commands are parsed with zero-copy semantics - the key and value fields reference slices of the original input buffer.
Variants§
Ping
PING command
Get
GET key
Set
SET key value [EX seconds] [PX milliseconds] [NX|XX]
Del
DEL key
MGet
MGET key [key …]
Config
CONFIG subcommand [args…]
Cluster
CLUSTER subcommand [args…]
Asking
ASKING — used before retrying a command after an ASK redirect
ReadOnly
READONLY — enable read queries on a replica node
ReadWrite
READWRITE — disable READONLY mode
FlushDb
FLUSHDB
FlushAll
FLUSHALL
Incr
INCR key - Increment the integer value of a key by one
Decr
DECR key - Decrement the integer value of a key by one
IncrBy
INCRBY key delta - Increment the integer value of a key by delta
DecrBy
DECRBY key delta - Decrement the integer value of a key by delta
Append
APPEND key value - Append a value to a key
HSet
HSET key field value [field value …] - Set field(s) in a hash
HGet
HGET key field - Get a field from a hash
HMGet
HMGET key field [field …] - Get multiple fields from a hash
HGetAll
HGETALL key - Get all fields and values from a hash
HDel
HDEL key field [field …] - Delete field(s) from a hash
HExists
HEXISTS key field - Check if field exists in a hash
HLen
HLEN key - Get the number of fields in a hash
HKeys
HKEYS key - Get all field names in a hash
HVals
HVALS key - Get all values in a hash
HSetNx
HSETNX key field value - Set field only if it doesn’t exist
HIncrBy
HINCRBY key field increment - Increment hash field by integer
LPush
LPUSH key element [element …] - Push to left of list
RPush
RPUSH key element [element …] - Push to right of list
LPop
LPOP key [count] - Pop from left of list
RPop
RPOP key [count] - Pop from right of list
LRange
LRANGE key start stop - Get range of elements
LLen
LLEN key - Get list length
LIndex
LINDEX key index - Get element by index
LSet
LSET key index element - Set element by index
LTrim
LTRIM key start stop - Trim list to range
LPushX
LPUSHX key element [element …] - Push to left only if list exists
RPushX
RPUSHX key element [element …] - Push to right only if list exists
SAdd
SADD key member [member …] - Add members to set
SRem
SREM key member [member …] - Remove members from set
SMembers
SMEMBERS key - Get all members of set
SIsMember
SISMEMBER key member - Check if member exists in set
SMisMember
SMISMEMBER key member [member …] - Check multiple members
SCard
SCARD key - Get set cardinality
SPop
SPOP key [count] - Remove and return random member(s)
SRandMember
SRANDMEMBER key [count] - Get random member(s) without removal
Type
TYPE key - Get the type of key
Implementations§
Source§impl<'a> Command<'a>
impl<'a> Command<'a>
Sourcepub fn parse(buffer: &'a [u8]) -> Result<(Self, usize), ParseError>
pub fn parse(buffer: &'a [u8]) -> Result<(Self, usize), ParseError>
Parse a command from a byte buffer using default limits.
Returns the parsed command and the number of bytes consumed.
§Zero-copy
The returned command contains references to the input buffer, so the buffer must outlive the command. This avoids allocation for keys and values.
§Errors
Returns ParseError::Incomplete if more data is needed.
Returns other errors for malformed or unknown commands.
Sourcepub fn parse_with_options(
buffer: &'a [u8],
options: &ParseOptions,
) -> Result<(Self, usize), ParseError>
pub fn parse_with_options( buffer: &'a [u8], options: &ParseOptions, ) -> Result<(Self, usize), ParseError>
Parse a command from a byte buffer with custom options.
This is useful for setting custom limits on bulk string size to prevent denial-of-service attacks or to enforce server-side value size limits.
§Zero-copy
The returned command contains references to the input buffer, so the buffer must outlive the command. This avoids allocation for keys and values.
§Errors
Returns ParseError::Incomplete if more data is needed.
Returns ParseError::BulkStringTooLong if a bulk string exceeds the limit.
Returns other errors for malformed or unknown commands.