Refactored cache key generation from adapters to entities.