Implementing a caching system