Giter VIP home page Giter VIP logo

Comments (7)

grantjenks avatar grantjenks commented on August 22, 2024

I agree this is a useful feature. Thank you for the code snippet. Pull request welcome.

from python-diskcache.

Suor avatar Suor commented on August 22, 2024

You might want to use Django caches .get_many()/.set_many() interface, just to not add new one :)

from python-diskcache.

tamirOK avatar tamirOK commented on August 22, 2024

Do get_many and set_many operations have to hit database only once?

from python-diskcache.

Suor avatar Suor commented on August 22, 2024

Can't see if that is important, this should obviously be more efficient than a cycle of gets or sets, but otherwise implementation could be arbitrary.

from python-diskcache.

grantjenks avatar grantjenks commented on August 22, 2024

As I've thought about it, I doubt you could do get_many or set_many in a single database query but you could do them in a single database transaction. The database should be smart about which pages it updates and syncs.

So, yes, those methods should use a single database transaction.

Also, I don't think any batching should be done inside those methods. I want batching left to the end-user. If we give them an API like I've described above then the end-user can easily batch keys/values (as they may want in the case where the number of keys/values is very large). Not batching will block concurrent writers but the scenario is similar to writing a large value.

from python-diskcache.

grantjenks avatar grantjenks commented on August 22, 2024

In v4, diskcache will support transactions. There will be a tutorial section on transactions that will show how to do the *-many variants in one transaction.

from python-diskcache.

grantjenks avatar grantjenks commented on August 22, 2024

The set_many example was added to the Transactions section of the tutorial at 126b033

from python-diskcache.

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.