pub struct MemoryCache { /* private fields */ }Expand description
In-memory cache implementation
Implementations§
Source§impl MemoryCache
impl MemoryCache
pub fn new(default_ttl: Option<Duration>) -> Self
pub async fn get(&self, key: &str) -> Option<String>
pub async fn set( &self, key: &str, value: &str, ttl: Option<Duration>, ) -> Result<(), Box<dyn Error>>
pub async fn delete(&self, key: &str) -> Result<bool, Box<dyn Error>>
pub async fn clear(&self) -> Result<(), Box<dyn Error>>
pub async fn cleanup_expired(&self) -> Result<usize, Box<dyn Error>>
pub async fn size(&self) -> usize
Trait Implementations§
Source§impl Cache for MemoryCache
impl Cache for MemoryCache
fn get( &self, key: &str, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + '_>>
fn set( &self, key: &str, value: &str, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + Send + '_>>
fn delete( &self, key: &str, ) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error>>> + Send + '_>>
Auto Trait Implementations§
impl Freeze for MemoryCache
impl !RefUnwindSafe for MemoryCache
impl Send for MemoryCache
impl Sync for MemoryCache
impl Unpin for MemoryCache
impl !UnwindSafe for MemoryCache
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