Giter VIP home page Giter VIP logo

Comments (1)

dgilland avatar dgilland commented on June 8, 2024 1

If you want to share cached data between multiple processes with cacehout, then some options would be:

  1. Create a single cacheout instance in the main process and then using inter-process communications to send cache operation requests from the child processes to the main process and cache results from the main process back to the child processes.
  2. Create a shared data structure that could be used as the backend for multiple cacheout instances. I.e. create the shared data structure in the main process, pass it into the child processes, and then each child process uses that shared data structure as the backend for its cacheout instance.

Option 1 doesn't have to worry about any of the internals of cacheout and you'd only be dealing with one instance of it, but you would be creating your own sort of cache "server". Each child process would be treated as a cache client. You could potentially use multiprocessing.Pipe, one for each child process where the main process would then loop over each parent end of the pipe and check if there's a cache operation request. Then the main process cache "server" would be like an RPC call where the child sends some message that corresponds to a method call in the main process on the cacheout instance.

Option 2 would require creating a multiprocess version of OrderedDict so that it could be assigned to cacheout.Cache._cache. Then you'd just need to create the data structure instance in the main process and then share it with each child process so they could set it in their instance of cacheout.

from cacheout.

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.