pub struct Cached<P> { /* private fields */ }Expand description
A provider wrapper that caches data locally.
Implementations§
source§impl<P: Provider + 'static> Cached<P>
impl<P: Provider + 'static> Cached<P>
sourcepub fn new(inner: P, dir: impl AsRef<Path>, pagesize: u64) -> Self
pub fn new(inner: P, dir: impl AsRef<Path>, pagesize: u64) -> Self
Create a new cache wrapper for the given provider.
Set the page size in bytes for cached chunks, as well as the directory where fragments should be stored.
sourcepub fn set_prefetch_depth(&mut self, n: u32)
pub fn set_prefetch_depth(&mut self, n: u32)
Prefetch the N-ahead chunk. Setting to 0 implies no prefetching.
sourcepub fn cleaner(&self) -> impl Future<Output = ()>
pub fn cleaner(&self) -> impl Future<Output = ()>
A background process that attempts to keep cache disk usage below 80%.
Since the cache directory is limited in size but local to the machine, it is acceptable to delete files from this folder at any time.
The process monitors the utilization level of the disk that the cache directory is on and removes random files from the cache when utilization exceeds 80%.
sourcepub fn stats_logger(&self) -> impl Future<Output = ()>
pub fn stats_logger(&self) -> impl Future<Output = ()>
A background process that logs stats
sourcepub fn stats_emitter(&self) -> impl Future<Output = ()>
pub fn stats_emitter(&self) -> impl Future<Output = ()>
A background process that emits stats to statsd
sourcepub async fn stats(&self) -> CacheStats
pub async fn stats(&self) -> CacheStats
Get a snapshot of current stats like volume of pending disk writes.
Trait Implementations§
source§impl<P: Provider + 'static> From<CacheConfig<P>> for Cached<P>
impl<P: Provider + 'static> From<CacheConfig<P>> for Cached<P>
source§fn from(config: CacheConfig<P>) -> Self
fn from(config: CacheConfig<P>) -> Self
Create a new cache wrapper for a provider with the given config.