pub enum Command<'a> {
Show 14 variants
Get {
key: &'a [u8],
},
Gets {
keys: Vec<&'a [u8]>,
},
Set {
key: &'a [u8],
flags: u32,
exptime: u32,
data: &'a [u8],
},
Add {
key: &'a [u8],
flags: u32,
exptime: u32,
data: &'a [u8],
},
Replace {
key: &'a [u8],
flags: u32,
exptime: u32,
data: &'a [u8],
},
Cas {
key: &'a [u8],
flags: u32,
exptime: u32,
data: &'a [u8],
cas_unique: u64,
},
Delete {
key: &'a [u8],
},
FlushAll,
Version,
Quit,
Incr {
key: &'a [u8],
delta: u64,
noreply: bool,
},
Decr {
key: &'a [u8],
delta: u64,
noreply: bool,
},
Append {
key: &'a [u8],
data: &'a [u8],
noreply: bool,
},
Prepend {
key: &'a [u8],
data: &'a [u8],
noreply: bool,
},
}Expand description
A parsed Memcache command with references to the original buffer.
Commands are parsed with zero-copy semantics where possible.
Variants§
Get
GET command
Gets
Multi-GET command
Set
SET command
Add
ADD command - store only if key doesn’t exist
Replace
REPLACE command - store only if key exists
Cas
CAS (compare-and-swap) command
Delete
DELETE command
FlushAll
FLUSH_ALL command
Version
VERSION command
Quit
QUIT command
Incr
INCR command - increment numeric value
Decr
DECR command - decrement numeric value
Append
APPEND command - append data to existing value
Prepend
PREPEND command - prepend data to existing value
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 options.
Returns the parsed command and the number of bytes consumed.
§Zero-copy
The returned command contains references to the input buffer for keys and data, avoiding allocation in the hot path.
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 allows configuring DoS protection limits like maximum key size, value size, and line length.