WIP: Cache invalidation by entity.

#6043 
WIP