pub struct MemcachedCache { /* private fields */ }Available on crate feature
memcached only.Expand description
Memcached distributed cache
This is an alternative L2 (warm tier) cache backend, providing:
- Distributed caching across multiple instances
- Simple key-value storage (no persistence)
- LRU eviction policy
- High throughput for read-heavy workloads
Note: Unlike Redis, Memcached does not support:
- TTL introspection (cannot get remaining TTL)
- Persistence to disk
- Advanced data structures
Implementations§
Source§impl MemcachedCache
impl MemcachedCache
Sourcepub fn new() -> CacheResult<Self>
pub fn new() -> CacheResult<Self>
Sourcepub fn get_server_stats(
&self,
) -> CacheResult<Vec<(String, HashMap<String, String>)>>
pub fn get_server_stats( &self, ) -> CacheResult<Vec<(String, HashMap<String, String>)>>
Get cache statistics (from Memcached server)
Returns server statistics like hits, misses, uptime, etc.
Each tuple contains (server_address, stats_map)
§Errors
Returns an error if the stats cannot be retrieved.
Trait Implementations§
Source§impl CacheBackend for MemcachedCache
Implement CacheBackend trait for MemcachedCache
impl CacheBackend for MemcachedCache
Implement CacheBackend trait for MemcachedCache
Source§fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Option<Bytes>>
fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Option<Bytes>>
Get value from cache by key Read more
Source§fn set_with_ttl<'a>(
&'a self,
key: &'a str,
value: Bytes,
ttl: Duration,
) -> BoxFuture<'a, CacheResult<()>>
fn set_with_ttl<'a>( &'a self, key: &'a str, value: Bytes, ttl: Duration, ) -> BoxFuture<'a, CacheResult<()>>
Set value in cache with time-to-live Read more
Source§fn remove<'a>(&'a self, key: &'a str) -> BoxFuture<'a, CacheResult<()>>
fn remove<'a>(&'a self, key: &'a str) -> BoxFuture<'a, CacheResult<()>>
Remove value from cache Read more
Source§fn set<'a>(
&'a self,
key: &'a str,
value: Bytes,
) -> BoxFuture<'a, CacheResult<()>>
fn set<'a>( &'a self, key: &'a str, value: Bytes, ) -> BoxFuture<'a, CacheResult<()>>
Set value in cache with default TTL (5 minutes)
Source§fn remove_pattern<'a>(
&'a self,
_pattern: &'a str,
) -> BoxFuture<'a, CacheResult<()>>
fn remove_pattern<'a>( &'a self, _pattern: &'a str, ) -> BoxFuture<'a, CacheResult<()>>
Remove keys matching a pattern Read more
Source§impl L2CacheBackend for MemcachedCache
impl L2CacheBackend for MemcachedCache
Auto Trait Implementations§
impl !RefUnwindSafe for MemcachedCache
impl !UnwindSafe for MemcachedCache
impl Freeze for MemcachedCache
impl Send for MemcachedCache
impl Sync for MemcachedCache
impl Unpin for MemcachedCache
impl UnsafeUnpin for MemcachedCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more