You are here

public function DeveloperStorage::resetCache in Apigee Edge 8

Resets the internal, static entity cache.

Parameters

$ids: (optional) If specified, the cache is reset for the entities with the given ids only.

Overrides EdgeEntityStorageBase::resetCache

File

src/Entity/Storage/DeveloperStorage.php, line 251

Class

DeveloperStorage
Entity storage implementation for developers.

Namespace

Drupal\apigee_edge\Entity\Storage

Code

public function resetCache(array $ids = NULL) {
  parent::resetCache($ids);

  // Ensure that if ids contains email addresses we also invalidate cache
  // entries that refers to the same entities by developer id and vice-versa.
  // See getPersistentCacheTags() for more insight.
  if ($ids && $this->entityType
    ->isPersistentlyCacheable()) {
    $tags = [];
    foreach ($ids as $id) {
      $tags[] = $this
        ->sanitizeCacheTag($id, "{$this->entityTypeId}:{$id}");
      $tags[] = $this
        ->sanitizeCacheTag($id, "{$this->entityTypeId}:{$id}:values");
    }
    Cache::invalidateTags($tags);
  }

  // Remove related entries in the developer company membership cache.
  if (empty($ids)) {
    $this->developerCompanies
      ->remove();
  }
  else {

    // We can not be sure whether ids are developer ids (UUIDs) or email
    // addresses so we invalidate entries by tags.
    $this->developerCompanies
      ->invalidate(array_map(function ($id) {
      return "developer:{$id}";
    }, $ids));
  }
}