9个版本
0.1.8 | 2024年3月15日 |
---|---|
0.1.7 | 2020年5月6日 |
0.1.6 | 2020年4月13日 |
0.1.3 | 2020年3月31日 |
389 在 算法 中排名
每月下载量 264
21KB
465 行
flexihash-rs
https://github.com/pda/flexihash 的Rust端口,旨在实现1:1兼容性
使用示例
use flexihash::Flexihash;
let fh = Flexihash::new();
// bulk add
fh.add_targets(vec!["cache-1", "cache-2", "cache-3"]);
// simple lookup
fh.lookup("object-a"); // "cache-1"
fh.lookup("object-b"); // "cache-2"
// add and remove
fh.add_target("cache-4");
fh.remove_target("cache-1");
// lookup with next-best fallback (for redundant writes)
fh.lookup_list("object", 2) // ["cache-2", "cache-4"]
// remove cache-2, expect object to hash to cache-4
fh.remove_target("cache-2")
fh.lookup("object") // "cache-4"
依赖项
~120KB