pub struct Client { /* private fields */ }Expand description
A ringline-native Memcache client wrapping a single connection.
Client::new(conn) creates a zero-overhead client with no callbacks or
metrics. Use Client::builder(conn) to configure per-request callbacks,
kernel timestamps, and built-in histogram tracking.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(conn: ConnCtx) -> Self
pub fn new(conn: ConnCtx) -> Self
Create a new client wrapping an established connection.
No callbacks, no metrics, no kernel timestamps — zero overhead.
Sourcepub fn builder(conn: ConnCtx) -> ClientBuilder
pub fn builder(conn: ConnCtx) -> ClientBuilder
Create a builder for a client with per-request callbacks.
Sourcepub fn metrics(&self) -> Option<&ClientMetrics>
pub fn metrics(&self) -> Option<&ClientMetrics>
Returns a reference to the built-in metrics, if enabled.
Sourcepub fn metrics_mut(&mut self) -> Option<&mut ClientMetrics>
pub fn metrics_mut(&mut self) -> Option<&mut ClientMetrics>
Returns a mutable reference to the built-in metrics, if enabled.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of in-flight requests.
Sourcepub fn fire_get(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>
pub fn fire_get(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>
Fire a GET request without waiting for the response.
Sourcepub fn fire_set(
&mut self,
key: &[u8],
value: &[u8],
flags: u32,
exptime: u32,
user_data: u64,
) -> Result<(), Error>
pub fn fire_set( &mut self, key: &[u8], value: &[u8], flags: u32, exptime: u32, user_data: u64, ) -> Result<(), Error>
Fire a SET request (with copy) without waiting for the response.
Sourcepub fn fire_set_with_guard<G: SendGuard>(
&mut self,
key: &[u8],
guard: G,
flags: u32,
exptime: u32,
user_data: u64,
) -> Result<(), Error>
pub fn fire_set_with_guard<G: SendGuard>( &mut self, key: &[u8], guard: G, flags: u32, exptime: u32, user_data: u64, ) -> Result<(), Error>
Fire a SET request with zero-copy value via SendGuard.
Sourcepub fn fire_delete(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>
pub fn fire_delete(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>
Fire a DELETE request without waiting for the response.
Sourcepub async fn recv(&mut self) -> Result<CompletedOp, Error>
pub async fn recv(&mut self) -> Result<CompletedOp, Error>
Receive the next completed operation from the pipeline.
Returns Err(Error::NoPending) if there are no in-flight requests.
Sourcepub async fn get(
&mut self,
key: impl AsRef<[u8]>,
) -> Result<Option<Value>, Error>
pub async fn get( &mut self, key: impl AsRef<[u8]>, ) -> Result<Option<Value>, Error>
Get the value of a key. Returns None on cache miss.
Sourcepub async fn gets(&mut self, keys: &[&[u8]]) -> Result<Vec<GetValue>, Error>
pub async fn gets(&mut self, keys: &[&[u8]]) -> Result<Vec<GetValue>, Error>
Get values for multiple keys. Returns only hits, each with its key and CAS token.
Sourcepub async fn set(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<(), Error>
pub async fn set( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<(), Error>
Set a key-value pair with default flags (0) and no expiration.
Sourcepub async fn set_with_options(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
flags: u32,
exptime: u32,
) -> Result<(), Error>
pub async fn set_with_options( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, flags: u32, exptime: u32, ) -> Result<(), Error>
Set a key-value pair with custom flags and expiration time.
Sourcepub async fn add(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<bool, Error>
pub async fn add( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<bool, Error>
Store a key only if it does not already exist (ADD command).
Returns true if stored, false if the key already exists.
Sourcepub async fn replace(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<bool, Error>
pub async fn replace( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<bool, Error>
Store a key only if it already exists (REPLACE command).
Returns true if stored, false if the key does not exist.
Sourcepub async fn incr(
&mut self,
key: impl AsRef<[u8]>,
delta: u64,
) -> Result<Option<u64>, Error>
pub async fn incr( &mut self, key: impl AsRef<[u8]>, delta: u64, ) -> Result<Option<u64>, Error>
Increment a numeric value by delta. Returns the new value after incrementing.
Returns None if the key does not exist.
Sourcepub async fn decr(
&mut self,
key: impl AsRef<[u8]>,
delta: u64,
) -> Result<Option<u64>, Error>
pub async fn decr( &mut self, key: impl AsRef<[u8]>, delta: u64, ) -> Result<Option<u64>, Error>
Decrement a numeric value by delta. Returns the new value after decrementing.
Returns None if the key does not exist.
Sourcepub async fn append(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<bool, Error>
pub async fn append( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<bool, Error>
Append data to an existing item’s value.
Returns true if stored, false if the key does not exist.
Sourcepub async fn prepend(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<bool, Error>
pub async fn prepend( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<bool, Error>
Prepend data to an existing item’s value.
Returns true if stored, false if the key does not exist.
Sourcepub async fn cas(
&mut self,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
cas_unique: u64,
) -> Result<bool, Error>
pub async fn cas( &mut self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, cas_unique: u64, ) -> Result<bool, Error>
Compare-and-swap: store the value only if the CAS token matches.
Returns Ok(true) if stored, Ok(false) if the CAS token didn’t match (EXISTS),
or Err if the key was not found or another error occurred.