Intrusive LRU Cache
This crate provides an LRU Cache implementation that is based on combining an intrusive doubly linked list and an intrusive red-black tree, in the same node. Both data structures share the same allocations, which makes it quite efficient for a linked structure.
The [LRUCache
] structure itself is not intrusive, and works like a regular cache. The intrusive part of the crate name is due to the
intrusive structures used internally.
Example
use LRUCache;
let mut lru: = default;
lru.insert;
lru.insert;
lru.insert;
let _ = lru.get; // updates LRU order
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Cargo Features
atomic
(default): Enables atomic links within the intrusive structures, making it thread-safe ifK
andV
areSend
/Sync
. If you disable this feature, you can still use the cache in a single-threaded context.