Skip to main content

Client

Struct Client 

Source
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

Source

pub fn new(conn: ConnCtx) -> Self

Create a new client wrapping an established connection.

No callbacks, no metrics, no kernel timestamps — zero overhead.

Source

pub fn builder(conn: ConnCtx) -> ClientBuilder

Create a builder for a client with per-request callbacks.

Source

pub fn conn(&self) -> ConnCtx

Returns the underlying connection context.

Source

pub fn metrics(&self) -> Option<&ClientMetrics>

Returns a reference to the built-in metrics, if enabled.

Source

pub fn metrics_mut(&mut self) -> Option<&mut ClientMetrics>

Returns a mutable reference to the built-in metrics, if enabled.

Source

pub fn pending_count(&self) -> usize

Number of in-flight requests.

Source

pub fn fire_get(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>

Fire a GET request without waiting for the response.

Source

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.

Source

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.

Source

pub fn fire_delete(&mut self, key: &[u8], user_data: u64) -> Result<(), Error>

Fire a DELETE request without waiting for the response.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn delete(&mut self, key: impl AsRef<[u8]>) -> Result<bool, Error>

Delete a key. Returns true if deleted, false if not found.

Source

pub async fn flush_all(&mut self) -> Result<(), Error>

Flush all items from the cache.

Source

pub async fn version(&mut self) -> Result<Box<str>, Error>

Get the server version string.

Source

pub async fn set_with_guard<G: SendGuard>( &mut self, key: &[u8], guard: G, flags: u32, exptime: u32, ) -> Result<(), Error>

SET with zero-copy value via SendGuard. The guard pins value memory until the kernel completes the send.

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !Send for Client

§

impl !Sync for Client

§

impl !UnwindSafe for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

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> 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, 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.