Improved algorithm for compound cache key generation.