Struct zng_task::http::FileSystemCache
source · pub struct FileSystemCache { /* private fields */ }
Expand description
A simple CacheDb
implementation that uses a local directory.
§Implementation Details
A file lock is used to control data access, read operations use a shared lock so concurrent reads can happen,
the set
operation uses a exclusive lock for the duration of the body download, so subsequent requests for
a caching resource will await until the cache is completed to return a body that will then read the cached data.
The set
operation returns a body as soon as the entry is created, the body will receive data as it is downloaded and cached,
in case of a cache error mid-download the cache entry is removed but the returned body will still download the rest of the data.
In case of an error creating the entry the original body is always returned so the Client
can continue with a normal
download also.
The cache does not pull data, only data read by the returned body is written to the cache, dropping the body without reading to end cancels the cache entry.
Implementations§
Trait Implementations§
source§impl CacheDb for FileSystemCache
impl CacheDb for FileSystemCache
source§fn clone_boxed(&self) -> Box<dyn CacheDb>
fn clone_boxed(&self) -> Box<dyn CacheDb>
source§fn policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
key
.source§fn set_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_policy<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
key
. Read moresource§fn body<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn body<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
key
.source§fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
body: Body,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
policy: CachePolicy,
body: Body,
) -> Pin<Box<dyn Future<Output = Option<Body>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
key
.source§impl Clone for FileSystemCache
impl Clone for FileSystemCache
source§fn clone(&self) -> FileSystemCache
fn clone(&self) -> FileSystemCache
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for FileSystemCache
impl RefUnwindSafe for FileSystemCache
impl Send for FileSystemCache
impl Sync for FileSystemCache
impl Unpin for FileSystemCache
impl UnwindSafe for FileSystemCache
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more