pub trait KeyBuilder<K: Hash + Eq + ?Sized> {
    fn hash_index(&self, key: &K) -> u64;

    fn hash_conflict(&self, key: &K) -> u64 { ... }
fn build_key(&self, k: &K) -> (u64, u64) { ... } }
Expand description

KeyBuilder is the hashing algorithm used for every key. In Stretto, the Cache will never store the real key. The key will be processed by KeyBuilder. Stretto has two default built-in key builder, one is TransparentKeyBuilder, the other is DefaultKeyBuilder. If your key implements TransparentKey trait, you can use TransparentKeyBuilder which is faster than DefaultKeyBuilder. Otherwise, you should use DefaultKeyBuilder You can also write your own key builder for the Cache, by implementing KeyBuilder trait.

Note that if you want 128bit hashes you should use the full (u64, u64), otherwise just fill the u64 at the 0 position, and it will behave like any 64bit hash.

Required methods

hash_index is used to hash the key to u64

Provided methods

if you want a 128bit hashes, you should implement this method, or leave this method return 0

build the key to 128bit hashes.

Implementors