implements caching.