pub struct Cache<K, V>where
K: Send + Clone + Hash + Eq + for<'de> Deserialize<'de> + Serialize,
V: Send + Clone + for<'de> Deserialize<'de> + Serialize,{ /* private fields */ }
Expand description
Persisting queried values to the disk across sessions.
Implementations§
Source§impl<K, V> Cache<K, V>where
K: Send + Clone + Hash + Eq + for<'de> Deserialize<'de> + Serialize,
V: Send + Clone + for<'de> Deserialize<'de> + Serialize,
impl<K, V> Cache<K, V>where
K: Send + Clone + Hash + Eq + for<'de> Deserialize<'de> + Serialize,
V: Send + Clone + for<'de> Deserialize<'de> + Serialize,
Sourcepub async fn get_or_insert_infallible<F>(
&self,
key: &K,
thunk: F,
) -> Result<Arc<V>, Error<()>>where
F: Future<Output = V>,
pub async fn get_or_insert_infallible<F>(
&self,
key: &K,
thunk: F,
) -> Result<Arc<V>, Error<()>>where
F: Future<Output = V>,
Get a value from the cache.
If this value is not in the cache, compute the thunk and insert the value.
Sourcepub async fn get_or_insert<F, E>(
&self,
key: &K,
thunk: F,
) -> Result<Arc<V>, Error<E>>
pub async fn get_or_insert<F, E>( &self, key: &K, thunk: F, ) -> Result<Arc<V>, Error<E>>
Get a value from the cache.
If this value is not in the cache, compute the thunk and insert the value.
pub fn cleanup_expired_from_memory_cache(&self)
pub fn cleanup_expired_disk_cache(&self)
Auto Trait Implementations§
impl<K, V> Freeze for Cache<K, V>
impl<K, V> !RefUnwindSafe for Cache<K, V>
impl<K, V> Send for Cache<K, V>
impl<K, V> Sync for Cache<K, V>
impl<K, V> Unpin for Cache<K, V>
impl<K, V> !UnwindSafe for Cache<K, V>
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