pub struct LruCacheStore { /* private fields */ }Expand description
Bounded in-process cache store using least-recently-used eviction.
Implementations§
Source§impl LruCacheStore
impl LruCacheStore
Sourcepub fn new(capacity: usize) -> CacheResult<Self>
pub fn new(capacity: usize) -> CacheResult<Self>
Creates a bounded LRU store.
Sourcepub fn with_metrics(self, metrics: MetricsRegistry) -> Self
pub fn with_metrics(self, metrics: MetricsRegistry) -> Self
Attaches a metrics registry to this L1 cache store.
Sourcepub async fn snapshot(&self) -> LruCacheSnapshot
pub async fn snapshot(&self) -> LruCacheSnapshot
Removes expired entries and returns the current snapshot.
Trait Implementations§
Source§impl CacheStore for LruCacheStore
impl CacheStore for LruCacheStore
Source§fn get_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads a raw value by key.
Source§fn set_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes a raw value with optional TTL.
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes a value by key.
Source§fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [CacheKey],
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [CacheKey],
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes multiple values by key. Read more
Source§fn get_json<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_json<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads a JSON value by key.
Source§impl Clone for LruCacheStore
impl Clone for LruCacheStore
Source§fn clone(&self) -> LruCacheStore
fn clone(&self) -> LruCacheStore
Returns a duplicate of the value. Read more
1.0.0 · 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 Freeze for LruCacheStore
impl !RefUnwindSafe for LruCacheStore
impl Send for LruCacheStore
impl Sync for LruCacheStore
impl Unpin for LruCacheStore
impl UnsafeUnpin for LruCacheStore
impl !UnwindSafe for LruCacheStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request