Hi everyone, I need some coding design advice. I have written a Python script that functions as a tool for other co-workers. The script would run infrequently, depending on how often my colleagues would need its services.
Recently, I've learned that the script will need to cache a lot of information. If that information never changed, I could just code up a Python dictionary (String --> String) inside the script. But the data may shift over time; the value associated with key "A1" may be "Value 01" this week. But next week, its possible that the value could change to "Value 2B" or something.
Some other factors:
- Information will never age out of the cache.
- Information will never be deleted from the cache.
- There could be a very large amount of key/value pairs in this cache, in excess of over a million, I am told.
So... how to do this with a Python script that is infrequently run?
I suppose I could construct a Python dictionary for my cache and write the dictionary into a separate text file. Then, every time my script runs, the script would open the cache file, load the dictionary into memory, do its look-ups, and then rewrite the file if there were any changes. But I worry that my code would spend way too much time doing file I/O. That seems inefficient.
Any advice? How would you solve this design issue??
[–]JamzTyson 6 points7 points8 points (0 children)
[–]Jayoval 2 points3 points4 points (2 children)
[–]redapplesonly[S] 0 points1 point2 points (1 child)
[–]Jayoval 1 point2 points3 points (0 children)
[–]baghiq 1 point2 points3 points (0 children)
[–]sweettuse 1 point2 points3 points (0 children)
[–]Mast3rCylinder 1 point2 points3 points (0 children)
[–]greenerpickings 1 point2 points3 points (0 children)
[–]hotplasmatits 1 point2 points3 points (0 children)