pub struct NoOpCache;Expand description
A cache that doesn’t actually cache anything.
Useful for:
- Testing without caching
- Disabling caching in production
- Debugging cache-related issues
§Example
use simple_agents_cache::NoOpCache;
use simple_agent_type::cache::Cache;
use std::time::Duration;
let cache = NoOpCache;
cache.set("key1", b"value1".to_vec(), Duration::from_secs(60)).await.unwrap();
let value = cache.get("key1").await.unwrap();
assert_eq!(value, None); // NoOpCache always returns NoneTrait Implementations§
Source§impl Cache for NoOpCache
impl Cache for NoOpCache
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a value from the cache. Read more
Source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_value: Vec<u8>,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_value: Vec<u8>,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Set a value in the cache with TTL. Read more
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a value from the cache. Read more
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all values from the cache. Read more
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Check if caching is enabled. Read more
impl Copy for NoOpCache
Auto Trait Implementations§
impl Freeze for NoOpCache
impl RefUnwindSafe for NoOpCache
impl Send for NoOpCache
impl Sync for NoOpCache
impl Unpin for NoOpCache
impl UnwindSafe for NoOpCache
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