pub struct ThingsCache { /* private fields */ }
Expand description
Main cache manager for Things 3 data with intelligent invalidation
Implementations§
Source§impl ThingsCache
impl ThingsCache
Sourcepub fn new(config: &CacheConfig) -> Self
pub fn new(config: &CacheConfig) -> Self
Create a new cache with the given configuration
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new cache with default configuration
Sourcepub async fn get_tasks<F, Fut>(
&self,
key: &str,
fetcher: F,
) -> Result<Vec<Task>>
pub async fn get_tasks<F, Fut>( &self, key: &str, fetcher: F, ) -> Result<Vec<Task>>
Get tasks from cache or execute the provided function Get tasks from cache or fetch if not cached
§Errors
Returns an error if the fetcher function fails.
Sourcepub async fn get_projects<F, Fut>(
&self,
key: &str,
fetcher: F,
) -> Result<Vec<Project>>
pub async fn get_projects<F, Fut>( &self, key: &str, fetcher: F, ) -> Result<Vec<Project>>
Get projects from cache or execute the provided function Get projects from cache or fetch if not cached
§Errors
Returns an error if the fetcher function fails.
Sourcepub async fn get_areas<F, Fut>(
&self,
key: &str,
fetcher: F,
) -> Result<Vec<Area>>
pub async fn get_areas<F, Fut>( &self, key: &str, fetcher: F, ) -> Result<Vec<Area>>
Get areas from cache or execute the provided function Get areas from cache or fetch if not cached
§Errors
Returns an error if the fetcher function fails.
Sourcepub async fn get_search_results<F, Fut>(
&self,
key: &str,
fetcher: F,
) -> Result<Vec<Task>>
pub async fn get_search_results<F, Fut>( &self, key: &str, fetcher: F, ) -> Result<Vec<Task>>
Get search results from cache or execute the provided function Get search results from cache or fetch if not cached
§Errors
Returns an error if the fetcher function fails.
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Invalidate all caches
Sourcepub async fn invalidate(&self, key: &str)
pub async fn invalidate(&self, key: &str)
Invalidate specific cache entry
Sourcepub fn get_stats(&self) -> CacheStats
pub fn get_stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset cache statistics
Sourcepub fn add_to_warming(&self, key: String, priority: u32)
pub fn add_to_warming(&self, key: String, priority: u32)
Add entry to cache warming list
Sourcepub fn remove_from_warming(&self, key: &str)
pub fn remove_from_warming(&self, key: &str)
Remove entry from cache warming list
Sourcepub fn invalidate_by_entity(&self, entity_type: &str, entity_id: Option<&Uuid>)
pub fn invalidate_by_entity(&self, entity_type: &str, entity_id: Option<&Uuid>)
Invalidate cache entries based on entity changes
Sourcepub fn invalidate_by_operation(&self, operation: &str)
pub fn invalidate_by_operation(&self, operation: &str)
Invalidate cache entries by operation type
Sourcepub fn get_warming_stats(&self) -> (usize, u32)
pub fn get_warming_stats(&self) -> (usize, u32)
Get cache warming statistics
Sourcepub fn stop_cache_warming(&mut self)
pub fn stop_cache_warming(&mut self)
Stop cache warming
Auto Trait Implementations§
impl Freeze for ThingsCache
impl !RefUnwindSafe for ThingsCache
impl Send for ThingsCache
impl Sync for ThingsCache
impl Unpin for ThingsCache
impl !UnwindSafe for ThingsCache
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
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more