pub struct AdaptiveCacheBuilder<RH = DefaultHashBuilder, REH = DefaultHashBuilder, FH = DefaultHashBuilder, FEH = DefaultHashBuilder> { /* private fields */ }
Expand description

AdaptiveCacheBuilder is used to help build a AdaptiveCache with custom configuration.

Implementations

Returns a default AdaptiveCacheBuilder.

Example

use rustc_hash::FxHasher;
use std::hash::BuildHasherDefault;
use caches::{Cache, AdaptiveCacheBuilder};

let mut cache = AdaptiveCacheBuilder::new(3)
    .set_recent_hasher(BuildHasherDefault::<FxHasher>::default())
    .set_recent_evict_hasher(BuildHasherDefault::<FxHasher>::default())
    .set_frequent_hasher(BuildHasherDefault::<FxHasher>::default())
    .set_frequent_evict_hasher(BuildHasherDefault::<FxHasher>::default())
    .finalize::<u64, u64>()
    .unwrap();

cache.put(1, 1);

Set the cache size

Set the recent LRU’s hash builder

Set the frequent LRU’s hash builder

Set the recent evict LRU’s hash builder

Set the frequent evict LRU’s hash builder

Finalize the builder to TwoQueueCache

Trait Implementations

Create a default AdaptiveCacheBuilder.

Example
use caches::{AdaptiveCacheBuilder, AdaptiveCache, Cache};
let mut cache: AdaptiveCache<u64, u64> = AdaptiveCacheBuilder::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.