Skip to main content

HttpCache

Trait HttpCache 

Source
pub trait HttpCache<T>: Send + Sync
where T: Send + Sync + Serialize + for<'de> Deserialize<'de>,
{ // Required methods fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry<T>>, CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn set<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: T, status_code: u16, state: CacheEntryState, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn update_state<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, state: CacheEntryState, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn cleanup<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn contains<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; }
Expand description

Core HTTP cache trait that backends must implement

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry<T>>, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a value from cache

Source

fn set<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: T, status_code: u16, state: CacheEntryState, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set or update a value in cache

Source

fn update_state<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, state: CacheEntryState, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update entry state

Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove entry from cache

Source

fn cleanup<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove stale/invalid/error entries

Source

fn contains<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a URL is cached

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> HttpCache<T> for FileHttpCache<T>
where T: Send + Sync + Serialize + for<'de> Deserialize<'de>,