pub struct TwoQueueCacheBuilder<RH = DefaultHashBuilder, FH = DefaultHashBuilder, GH = DefaultHashBuilder> { /* private fields */ }
Expand description

TwoQueueCacheBuilder is used to help build a TwoQueueCache with custom configuration.

Implementations

Returns a default TwoQueueCacheBuilder.

Example
use caches::{TwoQueueCacheBuilder, TwoQueueCache, Cache};
use rustc_hash::FxHasher;
use std::hash::BuildHasherDefault;

let mut cache = TwoQueueCacheBuilder::new(3)
    .set_recent_ratio(0.3)
    .set_ghost_ratio(0.4)
    .set_recent_hasher(BuildHasherDefault::<FxHasher>::default())
    .set_frequent_hasher(BuildHasherDefault::<FxHasher>::default())
    .set_ghost_hasher(BuildHasherDefault::<FxHasher>::default())
    .finalize::<u64, u64>()
    .unwrap();

cache.put(1, 1);

Set the ghost LRU size ratio

Set the recent LRU size ratio

Set the cache size

Set the recent LRU’s hash builder

Set the frequent LRU’s hash builder

Set the ghost LRU’s hash builder

Finalize the builder to TwoQueueCache

Trait Implementations

Create a default TwoQueueCacheBuilder.

Example
use caches::{TwoQueueCacheBuilder, TwoQueueCache, Cache};
let mut cache: TwoQueueCache<u64, u64> = TwoQueueCacheBuilder::default()
    .set_size(5)
    .finalize()
    .unwrap();

cache.put(1, 1);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.