Module collections::lru_cache
A cache that holds a limited number of key-value pairs. When the capacity of the cache is exceeded, the least-recently-used (where "used" means a look-up or putting the pair into the cache) pair is automatically removed.
Example
use collections::LruCache; let mut cache: LruCache<int, int> = LruCache::new(2); cache.put(1, 10); cache.put(2, 20); cache.put(3, 30); assert!(cache.get(&1).is_none()); assert_eq!(*cache.get(&2).unwrap(), 20); assert_eq!(*cache.get(&3).unwrap(), 30); cache.put(2, 22); assert_eq!(*cache.get(&2).unwrap(), 22); cache.put(6, 60); assert!(cache.get(&3).is_none()); cache.change_capacity(1); assert!(cache.get(&2).is_none());
Structs
LruCache | An LRU Cache. |