Struct timed_cache::TimedCache[][src]

pub struct TimedCache<Key: Hash + Eq + Clone, Value> { /* fields omitted */ }

A collection which stores a value for a set amount of time.

Each stored value will keep track of when it was stored, and once the value has been considered valid for the specified length of time, it will be re-generated using the generator function provided when attempting to retrieve a value using TimedCache::get.

Methods

impl<Key: Hash + Eq + Clone, Value> TimedCache<Key, Value>
[src]

Creates a TimedCache with the specified Duration as the length of time the values will be considered 'valid' after initial storage.

Retrieves a reference to the value stored in the cache for the key if it exists and is still considered valid, otherwise calls generate_value to generate the value to store in the cache and returns a reference to that value.

Auto Trait Implementations

impl<Key, Value> Send for TimedCache<Key, Value> where
    Key: Send,
    Value: Send

impl<Key, Value> Sync for TimedCache<Key, Value> where
    Key: Sync,
    Value: Sync