You are here

protected function DeveloperCache::doRemoveEntities in Apigee Edge 8

Allows to perform additional tasks after entities got deleted from cache.

Parameters

string[] $ids: Array of entity ids.

Overrides EntityCache::doRemoveEntities

File

src/Entity/Controller/Cache/DeveloperCache.php, line 93

Class

DeveloperCache
Default developer cache implementation.

Namespace

Drupal\apigee_edge\Entity\Controller\Cache

Code

protected function doRemoveEntities(array $ids) : void {
  if (!empty($ids)) {

    // If ids are developer ids (UUIDs).
    $dev_id_email_address_matches = array_intersect_key($this->developerIdEmailMap, array_flip($ids));

    // If ids are email addresses.
    $dev_id_email_address_matches += array_flip(array_intersect_key(array_flip($this->developerIdEmailMap), array_flip($ids)));

    // Because all cached entries tagged with email address and developer
    // id (UUID) this should invalidate everything that is needed in this
    // cache...
    $this->cacheBackend
      ->invalidateTags($ids);

    // ... although if $ids are developer ids (UUIDs) then the entity id cache
    // does not get invalidated properly in parent.
    $this->entityIdCache
      ->removeIds($dev_id_email_address_matches);

    // Remove removed items from the internal cache.
    $this->developerIdEmailMap = array_diff_key($this->developerIdEmailMap, $dev_id_email_address_matches);
  }
}