added support for query caching.