Fixed a bug where keys in the query cache were not updated properly when the cache was full, sometimes causing the wrong query to be run.