Implemented query caching.