final class AppCache in Apigee Edge 8
Default app cache implementation for app controllers.
See interface definition for more details,
This app cache implementation also keeps an internal list about apps by using using their app owners and app names as an id. The owner information is extracted from the app entity so it is either developer id (UUID) or company name. Developer email address is not acceptable here.
Hierarchy
- class \Drupal\apigee_edge\Entity\Controller\Cache\EntityCache implements EntityCacheInterface
- class \Drupal\apigee_edge\Entity\Controller\Cache\AppCache implements AppCacheInterface
Expanded class hierarchy of AppCache
1 string reference to 'AppCache'
1 service uses AppCache
File
- src/
Entity/ Controller/ Cache/ AppCache.php, line 40
Namespace
Drupal\apigee_edge\Entity\Controller\CacheView source
final class AppCache extends EntityCache implements AppCacheInterface {
/**
* An associative array with app owners, app names and app ids.
*
* Parent keys are app owners (developer UUID or company name), second level
* keys are app names and their values are app ids (UUIDs).
*
* This array can contain app ids that have been invalidated
* in cache. It is not a problem because this information is only used
* internally.
*
* @var array
*/
private $appOwnerAppNameAppIdMap = [];
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function getAppOwner(AppInterface $app) : string {
if ($app instanceof DeveloperAppInterface) {
return $app
->getDeveloperId();
}
elseif ($app instanceof CompanyAppInterface) {
return $app
->getCompanyName();
}
throw new RuntimeException('Unable to identify app owner.');
}
/**
* {@inheritdoc}
*/
public function getAppsByOwner(string $owner) : ?array {
if (!empty($this->appOwnerAppNameAppIdMap[$owner])) {
return $this
->getEntities($this->appOwnerAppNameAppIdMap[$owner]);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function removeAppsByOwner(string $owner) : void {
if (!empty($this->appOwnerAppNameAppIdMap[$owner])) {
$this
->removeEntities($this->appOwnerAppNameAppIdMap[$owner]);
unset($this->appOwnerAppNameAppIdMap[$owner]);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AppCache:: |
private | property | An associative array with app owners, app names and app ids. | |
AppCache:: |
public | function |
Returns the owner of an app. Overrides AppCacheInterface:: |
|
AppCache:: |
public | function |
Returns an app from the cache by its owner. Overrides AppCacheInterface:: |
|
AppCache:: |
protected | function |
Generates cache items for an entity. Overrides EntityCache:: |
|
AppCache:: |
public | function |
Remove all apps from the cache by their owner. Overrides AppCacheInterface:: |
|
EntityCache:: |
private | property | Indicates whether all entities in the cache or not. | |
EntityCache:: |
protected | property | The memory cache backend used by this cache. | |
EntityCache:: |
private | property | Array of entity ids stored in the cache. | |
EntityCache:: |
protected | property | The entity id cache related to this entity type. | |
EntityCache:: |
final public | function |
Changes whether all entities in the cache or not. Overrides EntityCacheInterface:: |
|
EntityCache:: |
protected | function | Allows to perform additional tasks after entities got deleted from cache. | 1 |
EntityCache:: |
protected | function | Allows to perform additional tasks after entities got saved to cache. | 1 |
EntityCache:: |
final public | function |
Returns entities from the cache. Overrides EntityCacheInterface:: |
|
EntityCache:: |
final public | function |
Returns an entity from the cache by its id. Overrides EntityCacheInterface:: |
|
EntityCache:: |
final public | function |
Returns whether all entities in cache or not. Overrides EntityCacheInterface:: |
|
EntityCache:: |
final public | function |
Removes entities from the cache by their ids. Overrides EntityCacheInterface:: |
|
EntityCache:: |
final public | function |
Saves entities to the cache. Overrides EntityCacheInterface:: |
|
EntityCache:: |
public | function | EntityCache constructor. | 1 |
EntityCache:: |
public | function | Prevents data stored in entity cache from being serialized. |