|
1
|
Shelving dictionaries are quick and easy, until they grow too large and access is slowed to a crawl. This recipe is a directory cache with the filename an md5 of the key and the value is the file contents (as a pickled dump).
The need for this came up when I was reading and storing thousands of RSS feeds (my own toy aggregator). No databases please. Shelving didn't work since it quickly grew to hundreds of megabytes and access obviously was hindered. The locking is optional (my app had multiple threads reading/updating the cache). If you don't need locking simple remove the "with self.lock" statements and the self.lock object in the cache itself.
Tags: files
|
Add a comment
Sign in to comment
Download
Copy to clipboard
