[][src]Crate lru_time_cache

Least Recently Used (LRU) Cache

Implementation of a Least Recently Used caching algorithm in a container which may be limited by size or time, ordered by most recently seen.

Examples

extern crate lru_time_cache;
use lru_time_cache::LruCache;

// Construct an `LruCache` of `<u8, String>`s, limited by key count
let max_count = 10;
let _lru_cache = LruCache::<u8, String>::with_capacity(max_count);

// Construct an `LruCache` of `<String, i64>`s, limited by expiry time
let time_to_live = ::std::time::Duration::from_millis(100);
let _lru_cache = LruCache::<String, i64>::with_expiry_duration(time_to_live);

// Construct an `LruCache` of `<u64, Vec<u8>>`s, limited by key count and expiry time
let _lru_cache = LruCache::<u64, Vec<u8>>::with_expiry_duration_and_capacity(time_to_live,
                                                                             max_count);

Structs

Iter

An iterator over an LruCache's entries that updates the timestamps as values are traversed. Values are produced in the most recently used order.

LruCache

Implementation of LRU cache.

NotifyIter

Much like Iter except will produce expired entries too where Iter silently drops them.

OccupiedEntry

An occupied Entry.

PeekIter

An iterator over an LruCache's entries that does not modify the timestamp.

VacantEntry

A vacant Entry.

Enums

Entry

A view into a single entry in an LRU cache, which may either be vacant or occupied.

TimedEntry

Entry produced by NotifyIter that might be still valid or expired.