Using merkle trees for query caching and updates