Cache Store Improvements

I want to bring your attention to a ticket regarding MemoryStore and
FileStore caching, and my proposed solution to some problems. You can
ignore most of my comments, the fourth one is the important one.

If you can, please test this patch out and let me know what you think.
All the tests pass, but I'm sure there are edge cases that need