Improve cache key handling for collections