You are here

protected function AppStorage::setPersistentCache in Apigee Edge 8

Stores entities in the persistent cache backend.

Parameters

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

Overrides EdgeEntityStorageBase::setPersistentCache

File

src/Entity/Storage/AppStorage.php, line 240

Class

AppStorage
Base entity storage class for developer and team (company) app entities.

Namespace

Drupal\apigee_edge\Entity\Storage

Code

protected function setPersistentCache(array $entities) {
  parent::setPersistentCache($entities);
  if (!$this->entityType
    ->isPersistentlyCacheable()) {
    return;
  }

  /** @var \Drupal\apigee_edge\Entity\AppInterface $entity */
  foreach ($entities as $entity) {

    // Create an additional cache entry for each app that stores the app id
    // for each developerId or company (team) name + app name combinations.
    // Thanks for this we can run queries faster that tries to an load app
    // by using these two properties instead of the app id.
    $this->cacheBackend
      ->set($this
      ->buildCacheIdForAppName($entity
      ->getAppOwner(), $entity
      ->getName()), $entity
      ->getAppId(), $this
      ->getPersistentCacheExpiration(), $this
      ->getPersistentCacheTagsForAppName($entity));
  }
}