pub struct Cache { /* private fields */ }Expand description
Typed cache API over a shared store.
Implementations§
Source§impl Cache
impl Cache
pub fn new(store: impl CacheStore) -> Cache
pub fn from_arc(store: Arc<dyn CacheStore>) -> Cache
pub fn store(&self) -> &Arc<dyn CacheStore> ⓘ
Sourcepub async fn get_or_insert_json<T, E, F, Fut>(
&self,
key: &str,
opts: CacheOptions,
f: F,
) -> Result<T, E>
pub async fn get_or_insert_json<T, E, F, Fut>( &self, key: &str, opts: CacheOptions, f: F, ) -> Result<T, E>
Memoize a serializable value. Stale values are recomputed inline;
errors from f are returned and nothing is cached.
Sourcepub async fn revalidate_path(&self, path: &str) -> Result<bool, CacheError>
pub async fn revalidate_path(&self, path: &str) -> Result<bool, CacheError>
Invalidate a cached page (ISR) so the next request re-renders it.
Sourcepub async fn revalidate_tag(&self, tag: &str) -> Result<usize, CacheError>
pub async fn revalidate_tag(&self, tag: &str) -> Result<usize, CacheError>
Invalidate every page and data entry tagged with tag.
pub async fn invalidate(&self, key: &str) -> Result<bool, CacheError>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Cache
impl !UnwindSafe for Cache
impl Forget for Cache
impl Freeze for Cache
impl Move for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin 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