Prototype for a more general method of caching results