Performance optimization to cache based on unique keys