Comments (1)
If you want to share cached data between multiple processes with cacehout, then some options would be:
- 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.
- 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)
- cacheout
- Are the default functions single-threaded? HOT 2
- Roadmap "Layered caching (multi-level caching)" HOT 2
- The in operator returns True after cache expiration HOT 2
- OrderedDict Mutated during Iteration HOT 1
- how about add a callback to expired object? HOT 1
- Update expire time for specific entrys HOT 2
- Why not using cache[key] = value? HOT 3
- How we can use it in webserver? HOT 4
- TTL setting is unclear according to the documentation HOT 1
- Can you add a new cache algorithm?
- Memoization to disk HOT 2
- Eviction callback HOT 7
- LRU cache get() with default throws KeyError HOT 1
- LRU cache throws KeyError on add() HOT 1
- A typo in docstring? HOT 1
- single key info HOT 1
- sanic web framework will it be safe ? HOT 1
- An error in LFU? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacheout.