Skip to main content

MemoryCache

Struct MemoryCache 

Source
pub struct MemoryCache { /* private fields */ }
Expand description

In-memory cache implementation

Implementations§

Source§

impl MemoryCache

Source

pub fn new(max_entries: Option<usize>) -> Self

Create new memory cache

Trait Implementations§

Source§

impl Cache for MemoryCache

Source§

fn set<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 str, value: &'life2 T, ttl_seconds: Option<u64>, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where T: Serialize + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store value in cache
Source§

fn get<'life0, 'life1, 'async_trait, T>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>
where T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get value from cache
Source§

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete value from cache
Source§

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if key exists in cache
Source§

fn expire<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ttl_seconds: u64, ) -> Pin<Box<dyn Future<Output = CacheResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set TTL for existing key
Source§

fn ttl<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CacheResult<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get TTL for key (None if key doesn’t exist or has no expiration)
Source§

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all cache entries
Source§

fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CacheResult<CacheStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get cache statistics
Source§

fn mget<'life0, 'async_trait, T>( &'life0 self, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = CacheResult<Vec<(String, Option<T>)>>> + Send + 'async_trait>>
where T: for<'de> Deserialize<'de> + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Get multiple values from cache
Source§

fn mset<'life0, 'async_trait, T>( &'life0 self, entries: Vec<(String, T, Option<u64>)>, ) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where T: Serialize + Send + Sync + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Set multiple values in cache
Source§

fn mdelete<'life0, 'async_trait>( &'life0 self, keys: Vec<String>, ) -> Pin<Box<dyn Future<Output = CacheResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete multiple keys from cache

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.