| Crates.io | rotating-bloom-filter |
| lib.rs | rotating-bloom-filter |
| version | 0.1.0 |
| created_at | 2025-05-29 18:52:12.553865+00 |
| updated_at | 2025-05-29 18:52:12.553865+00 |
| description | A probabilistic data structure that rotates out old items to maintain recent membership. |
| homepage | |
| repository | https://codeberg.org/reachable-systems/reach/src/branch/main/common/rotating-bloom-filter |
| max_upload_size | |
| id | 1694177 |
| size | 10,672 |
A probabilistic data structure that maintains recent items using a dual-buffer rotation mechanism.
RotatingBloomFilter provides membership testing for recently inserted items, with older items
automatically rotating out. Items are guaranteed to be retained for at least a minimum retention
period, typically remaining for up to twice that duration.
Time-limited tracking: Only maintains membership information for recently inserted items
Type flexible: Works with any hashable type
The filter maintains two internal Bloom filters:
When the minimum retention threshold is reached, the next buffer becomes the new current buffer, and a new next buffer is created.
use rotating_bloom_filter::RotatingBloomFilter;
use rand_core::OsRng;
let mut filter = RotatingBloomFilter::new(0.01, 1000, &mut OsRng);
filter.insert("hello");
assert!(filter.contains("hello"));
// "hello" will be retained for at least 1000 insertions, but sticks around to 2000 insertions if
// the filter continues to be used.