Struct object_cache::Cache
source · 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
sourcepub async fn save_obj<T>(&self, key: &str, obj: &T) -> Result<(), CacheError>where
T: ?Sized + Serialize + DeserializeOwned + Debug,
pub async fn save_obj<T>(&self, key: &str, obj: &T) -> Result<(), CacheError>where T: ?Sized + Serialize + DeserializeOwned + Debug,
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>where
T: ?Sized + Serialize + DeserializeOwned + Debug,
pub async fn save_obj_if_not_exist<T>( &self, key: &str, obj: &T ) -> Result<(), CacheError>where T: ?Sized + Serialize + DeserializeOwned + Debug,
save object with key, if already exist this will be ignored
sourcepub async fn get_obj<T>(&self, key: &str) -> Result<T, CacheError>where
T: ?Sized + Serialize + DeserializeOwned + Debug,
pub async fn get_obj<T>(&self, key: &str) -> Result<T, CacheError>where T: ?Sized + Serialize + DeserializeOwned + Debug,
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