A decorator for caching