pub struct Cache { /* private fields */ }Expand description
HTTP cache implementation.
Implementations§
Source§impl Cache
impl Cache
Sourcepub async fn new(config: CacheConfig) -> Result<Self>
pub async fn new(config: CacheConfig) -> Result<Self>
Create a new cache with the given configuration.
Sourcepub async fn get(&self, url: &str) -> Result<Option<CacheEntry>>
pub async fn get(&self, url: &str) -> Result<Option<CacheEntry>>
Get a cached entry for the given URL.
Sourcepub async fn put(
&self,
url: String,
content: &[u8],
etag: Option<String>,
last_modified: Option<u64>,
max_age: Option<u64>,
no_cache: bool,
) -> Result<()>
pub async fn put( &self, url: String, content: &[u8], etag: Option<String>, last_modified: Option<u64>, max_age: Option<u64>, no_cache: bool, ) -> Result<()>
Store content in the cache.
Sourcepub async fn validate(
&self,
url: &str,
server_etag: Option<&str>,
server_last_modified: Option<u64>,
) -> Result<bool>
pub async fn validate( &self, url: &str, server_etag: Option<&str>, server_last_modified: Option<u64>, ) -> Result<bool>
Validate cached entry against server metadata.
Sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get cache statistics.
Auto Trait Implementations§
impl !Freeze for Cache
impl !RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin 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