generalized caching