pub struct ServiceAdapter<K, V, S> { /* private fields */ }Available on crate feature
service only.Expand description
Adapter that converts a Service<CacheOperation> into a CacheTier.
This enables using service-based cache implementations (like Redis or Memcached)
as storage backends for Cache. The service can be composed with middleware
(retry, timeout, circuit breakers) before being wrapped by this adapter.
§Examples
ⓘ
// Convert any Service<CacheOperation> to a CacheTier
let adapter = ServiceAdapter::new(redis_service);
// Use as cache storage
let cache = Cache::builder(clock)
.storage(adapter)
.build();Implementations§
Source§impl<K, V, S> ServiceAdapter<K, V, S>
impl<K, V, S> ServiceAdapter<K, V, S>
Trait Implementations§
Source§impl<K, V, S> CacheTier<K, V> for ServiceAdapter<K, V, S>
impl<K, V, S> CacheTier<K, V> for ServiceAdapter<K, V, S>
Source§async fn get(&self, key: &K) -> Result<Option<CacheEntry<V>>, Error>
async fn get(&self, key: &K) -> Result<Option<CacheEntry<V>>, Error>
Gets a value, returning an error if the operation fails.
Source§async fn insert(&self, key: K, entry: CacheEntry<V>) -> Result<(), Error>
async fn insert(&self, key: K, entry: CacheEntry<V>) -> Result<(), Error>
Inserts or replaces a value, returning an error if the operation fails. Read more
Source§async fn invalidate(&self, key: &K) -> Result<(), Error>
async fn invalidate(&self, key: &K) -> Result<(), Error>
Invalidates a value, returning an error if the operation fails.
Source§async fn clear(&self) -> Result<(), Error>
async fn clear(&self) -> Result<(), Error>
Clears all entries, returning an error if the operation fails.
Source§impl<K, V, S> Clone for ServiceAdapter<K, V, S>
impl<K, V, S> Clone for ServiceAdapter<K, V, S>
Source§fn clone(&self) -> ServiceAdapter<K, V, S>
fn clone(&self) -> ServiceAdapter<K, V, S>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<K, V, S> Freeze for ServiceAdapter<K, V, S>where
S: Freeze,
impl<K, V, S> RefUnwindSafe for ServiceAdapter<K, V, S>
impl<K, V, S> Send for ServiceAdapter<K, V, S>
impl<K, V, S> Sync for ServiceAdapter<K, V, S>
impl<K, V, S> Unpin for ServiceAdapter<K, V, S>
impl<K, V, S> UnsafeUnpin for ServiceAdapter<K, V, S>where
S: UnsafeUnpin,
impl<K, V, S> UnwindSafe for ServiceAdapter<K, V, S>
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