You are here

protected function AppCache::prepareCacheItem in Apigee Edge 8

Generates cache items for an entity.

The cache id returned here must be always unique!

Parameters

\Apigee\Edge\Entity\EntityInterface $entity: The entity object that gets cached.

Return value

array Array of cache items. An array that CacheBackendInterface::setMultiple() can accept.

Overrides EntityCache::prepareCacheItem

See also

\Drupal\Core\Cache\CacheBackendInterface::setMultiple()

File

src/Entity/Controller/Cache/AppCache.php, line 59

Class

AppCache
Default app cache implementation for app controllers.

Namespace

Drupal\apigee_edge\Entity\Controller\Cache

Code

protected function prepareCacheItem(EntityInterface $entity) : array {

  /** @var \Apigee\Edge\Api\Management\Entity\AppInterface $entity */
  $owner = $this
    ->getAppOwner($entity);
  $item = [
    // We have to cache apps by their app ids here, $entity->id() returns
    // the name of the app.
    $entity
      ->getAppId() => [
      'data' => $entity,
      'tags' => [
        $entity
          ->getAppId(),
        $owner,
      ],
    ],
  ];
  $this->appOwnerAppNameAppIdMap[$owner][$entity
    ->getName()] = $entity
    ->getAppId();
  return $item;
}