Crates.io | dynamic-lru-cache |
lib.rs | dynamic-lru-cache |
version | 0.2.1 |
source | src |
created_at | 2021-11-24 05:24:28.119787 |
updated_at | 2023-10-09 14:12:49.203128 |
description | LRU Cache that only stores items recently seen more than once. |
homepage | |
repository | https://github.com/Cognoscan/dynamic-lru-cache |
max_upload_size | |
id | 486718 |
size | 30,130 |
A simple LRU cache for Rust that only caches items it has seen at least once before. The size of its internal memory is adjustable.
I didn't want to use a fixed cache size when I expect that most data will not be fetched twice, and that most of the time the number of items benefit from caching will be small. Good use cases: parsing large data structures that frequently cross-reference the same data chunk, reading a set of dictionary-compressed files where there are several different but shared dictionaries, reading many files that all refer to shared parser profiles (eg. color profiles in images), etc.
Sure, a fixed size cache that stores "seen once" items would also work, but the memory usage would be higher than really necessary. Hence, this crate.