Struct freqache::LFUCache[][src]

pub struct LFUCache<K, V, P> { /* fields omitted */ }

A weighted, thread-safe, futures-aware least-frequently-used cache

Implementations

impl<K: Clone + Eq + Hash, V: Entry, P: Policy<K, V>> LFUCache<K, V, P>[src]

pub fn new(capacity: u64, policy: P) -> Self[src]

Construct a new LFUCache.

pub fn contains_key<Q: ?Sized>(&mut self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Return true if the cache contains the given key.

pub async fn get<Q: ?Sized>(
    &mut self,
    key: &Q
) -> Option<impl Deref<Target = impl Deref<Target = V>>> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Borrow the value of the cache entry with the given key.

pub async fn insert(&mut self, key: K, value: V) -> bool[src]

Add a new entry to the cache.

pub fn is_empty(&self) -> bool[src]

Return true if the cache is empty.

pub fn is_full(&self) -> bool[src]

Return true if the cache is full.

pub fn len(&self) -> usize[src]

Return the number of entries in this cache.

pub async fn remove<Q>(&mut self, key: &Q) -> Option<V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Remove an entry from the cache, and clone and return its value if present.

pub async fn traverse<C: FnMut(&V) + Send>(&self, f: C)[src]

Traverse the cache values beginning with the least-frequent.

pub async fn evict(&mut self)[src]

Traverse the cache entries beginning with the least-frequent, and evict entries from the cache according to this its Policy.

Auto Trait Implementations

impl<K, V, P> RefUnwindSafe for LFUCache<K, V, P> where
    K: RefUnwindSafe,
    P: RefUnwindSafe

impl<K, V, P> Send for LFUCache<K, V, P> where
    K: Send,
    P: Send,
    V: Send

impl<K, V, P> Sync for LFUCache<K, V, P> where
    K: Send + Sync,
    P: Sync,
    V: Send

impl<K, V, P> Unpin for LFUCache<K, V, P> where
    K: Unpin,
    P: Unpin

impl<K, V, P> UnwindSafe for LFUCache<K, V, P> where
    K: UnwindSafe,
    P: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.