GithubHelp home page GithubHelp logo

Comments (8)

karlmcguire avatar karlmcguire commented on April 27, 2024

Are the values being returned by Get corrupted (as in, randomly mutated), or mismatched with other keys? If you can give me a general idea of how you're using it and the exact issue you were running into, I can invest time into this.

from ristretto.

apoggi-carecloud avatar apoggi-carecloud commented on April 27, 2024

Values returned by Get are corrupted, but there does not appear to be a consistent pattern and the errors will appear to randomly correct itself.

from ristretto.

johnnyfeng-bread avatar johnnyfeng-bread commented on April 27, 2024

@apoggi-carecloud Out of curiosity, does the cached data have anything referenced by pointers? Like slices or maps?

from ristretto.

apoggi-carecloud avatar apoggi-carecloud commented on April 27, 2024

@johnnyfeng-bread The cached data does contain slices and maps

from ristretto.

johnnyfeng-bread avatar johnnyfeng-bread commented on April 27, 2024

I might be wrong but I believe Ristretto places the data as is into a syncmap, which would mean that the original data, the cached copy, and any retrieved copies would all have the same pointer references. So a change to any one of the referenced values would change all of them. My suspicion is that's what's going on here.

from ristretto.

apoggi-carecloud avatar apoggi-carecloud commented on April 27, 2024

OK, so concurrent access is not safe then.

from ristretto.

johnnyfeng-bread avatar johnnyfeng-bread commented on April 27, 2024

Concurrent access should be safe for non-referenced types like strings or numbers. It's more that storing referenced values of any sort is not safe, whether or not it's accessed concurrently. So your data shouldn't include pointers, which means no slices or maps.

This would need someone from the Ristretto team to confirm, as I'm not 100% on the details of how this is implemented.

@karlmcguire

from ristretto.

karlmcguire avatar karlmcguire commented on April 27, 2024

Concurrent access to the cache is safe (as in, Get/Set/Del are all atomic operations). Ristretto guarantees that the values returned haven't been corrupted, but if the values are pointers there is no guarantee that the underlying data hasn't been mutated (if something else holds the pointer).

If enough people need a "transaction"-like API, we can look into adding that, where you can Get-Use-Set in one atomic operation, but for now I don't think we need it.

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.