Implementing database version of caching