factor caching functionality out of deep_pyramid; place it in a simple wrapper