Generalized dict caching.