GithubHelp home page GithubHelp logo

Update README/introduction docs about cachetools HOT 6 CLOSED

tkem avatar tkem commented on June 2, 2024
Update README/introduction docs

from cachetools.

Comments (6)

tkem avatar tkem commented on June 2, 2024

Maybe the docs should state more prominently that multi-threaded access to cache instances must be locked properly. Seems to be a recurring issue, e.g. #80, http://www.paulsprogrammingnotes.com/2016/08/python-cachetools-lrucache-keyerror.html.

from cachetools.

tkem avatar tkem commented on June 2, 2024

E.g. "contrary to popular believe, cache instances are not thread safe - neither is, for example, OrderedDict".

from cachetools.

tkem avatar tkem commented on June 2, 2024

BTW, is anywhere mentioned that the func decorators are thread-safe by default?

from cachetools.

jpivarski avatar jpivarski commented on June 2, 2024

Is this still true? I want to use cachetools.LRUCache (not the function decorator; the dict-like class) and share that cache across threads. I can guarantee that I will only read from it using

lrucache.get(keystring, None)

and only write to it using

lrucache[keystring] = array

I don't mind if reads are stale (correct for some time in the past), but I do want to be sure that I don't corrupt the state with concurrent __setitem__ or read an invalid result if the read is concurrent with a write.

Can I make these assumptions or do I need to lock it just to be safe? (Locking with my current cache implementation is a performance bottleneck.)

from cachetools.

tkem avatar tkem commented on June 2, 2024

You need to lock all access to the cache.

from cachetools.

jpivarski avatar jpivarski commented on June 2, 2024

Okay, thanks for the info.

from cachetools.

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.