#一致性哈希 #哈希 #查找 #端口 #跟随 #API #兼容性

flexihash

遵循API并兼容flexihash-php和flexihash-py的一致性哈希

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算法 中排名

Download history

每月下载量 264

MIT 许可证

21KB
465

flexihash-rs

Unit Tests

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