Struct poolcache::PoolCache [] [src]

pub struct PoolCache<Key, Value> {
    // some fields omitted
}

Methods

impl<Key, Value> PoolCache<Key, Value> where Key: PartialOrd + Ord + Clone

fn new(max_heat: u64) -> PoolCache<Key, Value>

Create a new PoolCache where the maximum heat of a value is limited to max_heat.

fn contains_key(&self, key: &Key) -> bool

Returns true if the given key is present in the cache.

fn get(&self, key: &Key) -> Option<&Value>

Returns a reference to the value associated with key, or None if the key is not present in the cache.

fn put(&mut self, val: Value)

Add a new object to the pool, not associated with any key. This will become available to any callers of take.

fn insert(&mut self, key: Key, val: Value)

Insert val into the map associated with key. Any previous entry for key will be replaced, and the old value will become available for new callers of take.

fn take(&mut self) -> Option<Value>

Take returns an object from the pool, evicting the least-used cached key if necessary. Returns None only if the PoolCache contains no items.