You are here

protected function EntityStorageBase::getFromStaticCache in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::getFromStaticCache()
  2. 9 core/lib/Drupal/Core/Entity/EntityStorageBase.php \Drupal\Core\Entity\EntityStorageBase::getFromStaticCache()

Gets entities from the static cache.

Parameters

array $ids: If not empty, return entities that match these IDs.

Return value

\Drupal\Core\Entity\EntityInterface[] Array of entities from the entity cache, keyed by entity ID.

1 call to EntityStorageBase::getFromStaticCache()
EntityStorageBase::loadMultiple in core/lib/Drupal/Core/Entity/EntityStorageBase.php
Loads one or more entities.

File

core/lib/Drupal/Core/Entity/EntityStorageBase.php, line 177

Class

EntityStorageBase
A base entity storage class.

Namespace

Drupal\Core\Entity

Code

protected function getFromStaticCache(array $ids) {
  $entities = [];

  // Load any available entities from the internal cache.
  if ($this->entityType
    ->isStaticallyCacheable()) {
    foreach ($ids as $id) {
      if ($cached = $this->memoryCache
        ->get($this
        ->buildCacheId($id))) {
        $entities[$id] = $cached->data;
      }
    }
  }
  return $entities;
}