GithubHelp home page GithubHelp logo

Comments (3)

martinmr avatar martinmr commented on April 27, 2024

Depends on your keyToHash function but the following is true of the default keyToHash function.

For bytes, and integer types, the key hash is uint64(k) and the conflict key is 0. So if the keys are different, so will be their hash.

For byte arrays and strings, the key hash is memhash(k, uintptr(len(k))) and the conflict hash is xxhash.Sum64(k). memhash is implemented in the runtime library and xxhash is from this library "github.com/cespare/xxhash".

I don't know the details of each implementation but given that we use two different hashes that seem to have low collision rates, the chance of the two algorithms returning the same answer for two different keys are very low. I don't think you need to worry about it by checking the value every time.

from ristretto.

linger1216 avatar linger1216 commented on April 27, 2024

I understand, the probability is very, very small, but there is still the limiting case, thanks.
I have another question about expiration, I create a new issue. :)

from ristretto.

reyoung avatar reyoung commented on April 27, 2024

It seems that you can same an extra key in value, and manually check the key is same or not.

from ristretto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.