function ContentEntityStorageBase::setPersistentCache

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::setPersistentCache()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::setPersistentCache()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::setPersistentCache()

Stores entities in the persistent cache backend.

Parameters

\Drupal\Core\Entity\ContentEntityInterface[] $entities: Entities to store in the cache.

1 call to ContentEntityStorageBase::setPersistentCache()
SqlContentEntityStorage::doLoadMultiple in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
Performs storage-specific loading of entities.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 1104

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function setPersistentCache($entities) {
    if (!$this->entityType
        ->isPersistentlyCacheable()) {
        return;
    }
    $cache_tags = [
        $this->entityTypeId . '_values',
        'entity_field_info',
    ];
    $items = [];
    foreach ($entities as $id => $entity) {
        $items[$this->buildCacheId($id)] = [
            'data' => $entity,
            'tags' => $cache_tags,
        ];
    }
    $this->cacheBackend
        ->setMultiple($items);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.