Fix cache key collision and add test for cache key distinctness.
Merge pull request #7478 from ahlmss/TST7420

Fix cache key collision and add test for cache key distinctness.