pub struct MockCacheProvider {
pub should_succeed: bool,
pub enabled: bool,
pub hit_ratio: f64,
pub mock_stats: CacheStats,
}
Expand description
Mock cache provider for testing
Fields§
§should_succeed: bool
Whether cache operations should succeed
enabled: bool
Whether cache is enabled
hit_ratio: f64
Mock cache hit ratio (0.0 - 1.0)
mock_stats: CacheStats
Mock stats
Trait Implementations§
Source§impl CacheProvider for MockCacheProvider
impl CacheProvider for MockCacheProvider
Source§fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = Option<T>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, T>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = Option<T>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a value from the cache
Source§fn set<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
_value: &'life2 T,
_ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
fn set<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, _key: &'life1 (impl 'async_trait + CacheKey), _value: &'life2 T, _ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
Set a value in the cache with optional TTL
Source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove a value from the cache
Source§fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all values from the cache
Source§fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 (impl 'async_trait + CacheKey),
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a key exists in the cache
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheStats> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = CacheStats> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get cache statistics
Source§fn set_enabled(&mut self, enabled: bool)
fn set_enabled(&mut self, enabled: bool)
Set cache enabled/disabled state
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Check if cache is enabled
Source§impl Clone for MockCacheProvider
impl Clone for MockCacheProvider
Source§fn clone(&self) -> MockCacheProvider
fn clone(&self) -> MockCacheProvider
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 moreSource§impl Debug for MockCacheProvider
impl Debug for MockCacheProvider
Auto Trait Implementations§
impl Freeze for MockCacheProvider
impl RefUnwindSafe for MockCacheProvider
impl Send for MockCacheProvider
impl Sync for MockCacheProvider
impl Unpin for MockCacheProvider
impl UnwindSafe for MockCacheProvider
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