I was skimming the ristretto source code and noticed that when fetching/storing a key in the Cache only the hash(es) are used/stored, the original key value is not retained. This was surprising to me since it differs from Golang’s map type which uses a hash map but also includes a final equality check to prevent hash collisions. I understand the odds of a hash collision given the use of two different hashing algorithms (memhash, xxhash) is very low, but I don’t see that behavior documented anywhere. Is my understanding correct? Could/should the README and/or godoc describe this behavior?
I did the same and discovered that all int keys are hashed with the 64 bit hash uint64(k).
This produces a collision for numbers (9223372036404770808 + n, -9223372036404770808 + n), like
and so on.
It’s really important to always use 128 bit hashes and hope for the best (i.e. no collision).