- if (($return = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) {
+ // If an entity does not have a UUID, either from not being set or from not
+ // having them, use the 'entity type:ID' pattern as the cache $cid.
+ $cid = $entity->uuid() ?: $entity->getEntityTypeId() . ':' . $entity->id();
+
+ // If the entity is revisionable, then append the revision ID to allow
+ // individual revisions to have specific access control and be cached
+ // separately.
+ if ($entity instanceof RevisionableInterface) {
+ /** @var $entity \Drupal\Core\Entity\RevisionableInterface */
+ $cid .= ':' . $entity->getRevisionId();
+ }
+
+ if (($return = $this->getCache($cid, $operation, $langcode, $account)) !== NULL) {