pub struct Cache<FE> { /* private fields */ }
Expand description
An in-memory cache layer over tokio::fs
with least-frequently-used (LFU) eviction.
Implementations
sourceimpl<FE: FileLoad + Send + Sync + 'static> Cache<FE>
impl<FE: FileLoad + Send + Sync + 'static> Cache<FE>
sourcepub fn new(
capacity: usize,
cleanup_interval: Duration,
max_file_handles: Option<usize>
) -> Arc<Self>
pub fn new(
capacity: usize,
cleanup_interval: Duration,
max_file_handles: Option<usize>
) -> Arc<Self>
Initialize the cache.
cleanup_interval
specifies how often cache cleanup should run in the background.
max_file_handles
specifies how many files are allowed to be evicted at once.
If not specified, max_file_handles
will default to 512.
This function should only be called once.
Panics: if max_file_handles
is Some(0)
Auto Trait Implementations
impl<FE> RefUnwindSafe for Cache<FE>
impl<FE> Send for Cache<FE>where
FE: Send + Sync,
impl<FE> Sync for Cache<FE>where
FE: Send + Sync,
impl<FE> Unpin for Cache<FE>
impl<FE> UnwindSafe for Cache<FE>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> Match for F
impl<F> Match for F
sourcefn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
Returns
true
if self
can be cast into the target type T
.sourceimpl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
sourcefn can_cast_from(&F) -> bool
fn can_cast_from(&F) -> bool
Test if
value
can be cast into Self
.sourcefn opt_cast_from(f: F) -> Option<T>
fn opt_cast_from(f: F) -> Option<T>
Returns
Some(Self)
if the source value can be cast into Self
, otherwise None
.sourcefn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err>where
OnErr: FnOnce(&T) -> Err,
fn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err>where
OnErr: FnOnce(&T) -> Err,
Returns
Ok(Self)
if the source value can be cast into Self
, otherwise calls on_err
.sourceimpl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
sourcefn can_cast_into(&self) -> bool
fn can_cast_into(&self) -> bool
Test if
self
can be cast into T
.sourcefn opt_cast_into(self) -> Option<T>
fn opt_cast_into(self) -> Option<T>
Returns
Some(T)
if self
can be cast into T
, otherwise None
.sourcefn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err>where
OnErr: FnOnce(&Self) -> Err,
Returns
Ok(T)
if self
can be cast into T
, otherwise calls on_err
.