Make caching easier for non-memory caches.
Merge pull request #345 from mschulkind/cache_fix

Make caching easier for non-memory caches.