Implementation for caching.