7 个版本

0.2.1 2024 年 7 月 1 日
0.2.0 2024 年 5 月 16 日
0.1.4 2024 年 1 月 17 日

42缓存 中排名

Download history · Rust 包仓库 77/week @ 2024-05-02 · Rust 包仓库 39/week @ 2024-05-09 · Rust 包仓库 202/week @ 2024-05-16 · Rust 包仓库 60/week @ 2024-05-23 · Rust 包仓库 80/week @ 2024-05-30 · Rust 包仓库 73/week @ 2024-06-06 · Rust 包仓库 165/week @ 2024-06-13 · Rust 包仓库 180/week @ 2024-06-20 · Rust 包仓库 533/week @ 2024-06-27 · Rust 包仓库 724/week @ 2024-07-04 · Rust 包仓库 1166/week @ 2024-07-11 · Rust 包仓库 1295/week @ 2024-07-18 · Rust 包仓库 973/week @ 2024-07-25 · Rust 包仓库 984/week @ 2024-08-01 · Rust 包仓库 580/week @ 2024-08-08 · Rust 包仓库 711/week @ 2024-08-15 · Rust 包仓库

每月下载量 3,488
encrypted-dns 中使用

MIT 许可

11KB
193

dependency status

SIEVE 缓存

这是 Rust 的 SIEVE 缓存替换算法的实现。

SIEVE 是一个比 LRU 更简单的淘汰算法,在偏斜工作负载上实现了最先进的效率。

此实现公开了与 clock-proarc-cache crate 相同的 API,因此可以用作现有应用程序中它们的直接替代品。

使用示例

use sieve_cache::SieveCache;

// Create a new cache with a capacity of 100000.
let mut cache: SieveCache<String, String> = SieveCache::new(100000).unwrap();

// Insert key/value pairs into the cache.
cache.insert("foo".to_string(), "foocontent".to_string());
cache.insert("bar".to_string(), "barcontent".to_string());

// Remove an entry from the cache.
cache.remove("bar");

// Retrieve a value from the cache, returning `None` or a reference to the value.
assert_eq!(cache.get("foo"), Some(&"foocontent".to_string()));

// Check if a key is in the cache.
assert_eq!(cache.contains_key("bar"), false);

// Get a mutable reference to a value in the cache.
if let Some(value) = cache.get_mut("foo") {
   *value = "newfoocontent".to_string();
}

// Return the number of cached values.
assert_eq!(cache.len(), 1);

// Return the capacity of the cache.
assert_eq!(cache.capacity(), 100000);

无运行时依赖