protected ContentEntityStorageBase::getFromPersistentCache(array &$ids = NULL)
Gets entities from the persistent cache backend.
Parameters
array|null &$ids: If not empty, return entities that match these IDs. IDs that were found will be removed from the list.
Return value
\Drupal\Core\Entity\ContentEntityInterface[] Array of entities from the persistent cache.
File
- core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 583
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | protected function getFromPersistentCache( array & $ids = NULL) { if (! $this ->entityType->isPersistentlyCacheable() || empty ( $ids )) { return array (); } $entities = array (); // Build the list of cache entries to retrieve. $cid_map = array (); foreach ( $ids as $id ) { $cid_map [ $id ] = $this ->buildCacheId( $id ); } $cids = array_values ( $cid_map ); if ( $cache = $this ->cacheBackend->getMultiple( $cids )) { // Get the entities that were found in the cache. foreach ( $ids as $index => $id ) { $cid = $cid_map [ $id ]; if (isset( $cache [ $cid ])) { $entities [ $id ] = $cache [ $cid ]->data; unset( $ids [ $index ]); } } } return $entities ; } |
Please login to continue.