Query cache management