pub struct ProviderCache {
pub cache: Arc<Mutex<HashMap<String, CacheEntry>>>,
}Expand description
Global cache for provider results with automatic cleanup
Fields§
§cache: Arc<Mutex<HashMap<String, CacheEntry>>>Implementations§
Source§impl ProviderCache
impl ProviderCache
Sourcepub fn get<T: Clone + Send + Sync + 'static>(&self, key: &str) -> Option<T>
pub fn get<T: Clone + Send + Sync + 'static>(&self, key: &str) -> Option<T>
Get a cached result by key
Sourcepub fn get_with_expiration<T: Clone + Send + Sync + 'static>(
&self,
key: &str,
expiration: Option<Duration>,
) -> Option<T>
pub fn get_with_expiration<T: Clone + Send + Sync + 'static>( &self, key: &str, expiration: Option<Duration>, ) -> Option<T>
Get a cached result by key, checking for expiration with a specific expiration duration
Sourcepub fn get_with_staleness<T: Clone + Send + Sync + 'static>(
&self,
key: &str,
stale_time: Option<Duration>,
expiration: Option<Duration>,
) -> Option<(T, bool)>
pub fn get_with_staleness<T: Clone + Send + Sync + 'static>( &self, key: &str, stale_time: Option<Duration>, expiration: Option<Duration>, ) -> Option<(T, bool)>
Get cached data with staleness information for SWR behavior
Sourcepub fn set<T: Clone + Send + Sync + 'static>(&self, key: String, value: T)
pub fn set<T: Clone + Send + Sync + 'static>(&self, key: String, value: T)
Set a cached result by key
Sourcepub fn invalidate(&self, key: &str)
pub fn invalidate(&self, key: &str)
Invalidate a cached result by key (alias for remove)
Sourcepub fn cleanup_unused_entries(&self, unused_threshold: Duration) -> usize
pub fn cleanup_unused_entries(&self, unused_threshold: Duration) -> usize
Clean up unused entries based on access time
Sourcepub fn evict_lru_entries(&self, max_size: usize) -> usize
pub fn evict_lru_entries(&self, max_size: usize) -> usize
Evict least recently used entries to maintain cache size limit
Sourcepub fn maintain(&self) -> CacheMaintenanceStats
pub fn maintain(&self) -> CacheMaintenanceStats
Perform comprehensive cache maintenance
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Source§impl Clone for ProviderCache
impl Clone for ProviderCache
Source§fn clone(&self) -> ProviderCache
fn clone(&self) -> ProviderCache
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ProviderCache
impl Default for ProviderCache
Source§fn default() -> ProviderCache
fn default() -> ProviderCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ProviderCache
impl RefUnwindSafe for ProviderCache
impl Send for ProviderCache
impl Sync for ProviderCache
impl Unpin for ProviderCache
impl UnwindSafe for ProviderCache
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> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
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<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.