Add cq to the cache. If there is already an entry for cq in the cache
then the current entry is returned and nothing is done. This avoids the
need to synchronize on this cache during query compilation. It is
possible that two threads might compile the same query after discovering
that it is not in cache but this is ok.