Struct blobnet::provider::Cached

source ·
pub struct Cached<P> { /* private fields */ }
Expand description

A provider wrapper that caches data locally.

Implementations§

source§

impl<P: Provider + 'static> Cached<P>

source

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.

source

pub fn set_prefetch_depth(&mut self, n: u32)

Prefetch the N-ahead chunk. Setting to 0 implies no prefetching.

source

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%.

source

pub fn stats_logger(&self) -> impl Future<Output = ()>

A background process that logs stats

source

pub fn stats_emitter(&self) -> impl Future<Output = ()>

A background process that emits stats to statsd

source

pub async fn stats(&self) -> CacheStats

Get a snapshot of current stats like volume of pending disk writes.

Trait Implementations§

source§

impl<P> Drop for Cached<P>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<P: Provider + 'static> From<CacheConfig<P>> for Cached<P>

source§

fn from(config: CacheConfig<P>) -> Self

Create a new cache wrapper for a provider with the given config.

source§

impl<P: Provider + 'static> Provider for Cached<P>

source§

fn head<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a file exists and returns its size in bytes. Read more
source§

fn get<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, range: Option<(u64, u64)> ) -> Pin<Box<dyn Future<Output = Result<BlobRead<'static>, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the data from the file at the given path. Read more
source§

fn put<'life0, 'life1, 'async_trait>( &'life0 self, data: ReadStream<'life1> ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Adds a binary blob to storage, returning its hash. Read more
source§

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

Asynchronously preload a list of blobs into local caches.

Auto Trait Implementations§

§

impl<P> !RefUnwindSafe for Cached<P>

§

impl<P> Send for Cached<P>where P: Send + Sync,

§

impl<P> Sync for Cached<P>where P: Send + Sync,

§

impl<P> Unpin for Cached<P>

§

impl<P> !UnwindSafe for Cached<P>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more