[Answered ]-Implement cache in Python

2👍

If you want multiple processes to be able to access the same data (e.g., the value of threshold_time), then you need some sort of persistent storage or a protocol for getting and setting the data. To be more specific, in your cache.py file, you need to save the value of threshold_time somewhere once you’ve computed it. Then your main.py can retrieve that value from wherever it’s been saved.

Just from what you listed, this seems like a particularly good use case for redis, but sqlite or even a text file would also work. Each persistence strategy comes with its own levels of data integrity and complexity.

Leave a comment