pub struct Cache { /* private fields */ }
Expand description
Main Struct for Cache
Implementations§
Source§impl Cache
impl Cache
Sourcepub async fn build(in_memory: bool, cache_file_name: &str) -> Self
pub async fn build(in_memory: bool, cache_file_name: &str) -> Self
build cache storage if in_memory = true, will create cache that will be erased after application closed if in_memory = false, will create a file in the project folder itself to store data
pub async fn build_simple( cache_file_name: Option<String>, ) -> Result<Cache, CacheError>
Sourcepub async fn save_obj<T>(&self, key: &str, obj: &T) -> Result<(), CacheError>
pub async fn save_obj<T>(&self, key: &str, obj: &T) -> Result<(), CacheError>
save object with key, if already exist this will replace
Sourcepub async fn save_obj_if_not_exist<T>(
&self,
key: &str,
obj: &T,
) -> Result<(), CacheError>
pub async fn save_obj_if_not_exist<T>( &self, key: &str, obj: &T, ) -> Result<(), CacheError>
save object with key, if already exist this will be ignored
Sourcepub async fn get_obj<T>(&self, key: &str) -> Result<T, CacheError>
pub async fn get_obj<T>(&self, key: &str) -> Result<T, CacheError>
will retrieve the object for the key
Sourcepub async fn get_all_objs(&self) -> Result<Vec<CacheData>, CacheError>
pub async fn get_all_objs(&self) -> Result<Vec<CacheData>, CacheError>
get all saved objects from the Cache
pub async fn pretty_print_all_cache(&self)
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
clears all cache data
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cache
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl !UnwindSafe for Cache
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> 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>
Converts
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>
Converts
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