final class DeveloperCompaniesCache in Apigee Edge 8
Default non-persistent developer company membership cache implementation.
Hierarchy
- class \Drupal\apigee_edge\Entity\DeveloperCompaniesCache implements DeveloperCompaniesCacheInterface
Expanded class hierarchy of DeveloperCompaniesCache
1 string reference to 'DeveloperCompaniesCache'
1 service uses DeveloperCompaniesCache
File
- src/
Entity/ DeveloperCompaniesCache.php, line 29
Namespace
Drupal\apigee_edge\EntityView source
final class DeveloperCompaniesCache implements DeveloperCompaniesCacheInterface {
/**
* The memory cache backend.
*
* @var \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface
*/
private $backend;
/**
* DeveloperCompaniesCache constructor.
*
* @param \Drupal\apigee_edge\MemoryCacheFactoryInterface $memory_cache_factory
* The memory cache factory service.
*/
public function __construct(MemoryCacheFactoryInterface $memory_cache_factory) {
$this->backend = $memory_cache_factory
->get('developer_companies');
}
/**
* {@inheritdoc}
*/
public function getCompanies(string $id) : ?array {
$item = $this->backend
->get($id);
return $item ? $item->data : NULL;
}
/**
* {@inheritdoc}
*/
public function saveCompanies(array $developers) : void {
/** @var \Apigee\Edge\Api\Management\Entity\DeveloperInterface $developer */
foreach ($developers as $developer) {
$tags = array_merge([
"developer:{$developer->getDeveloperId()}",
"developer:{$developer->getEmail()}",
], array_map(function (string $company) {
return "company:{$company}";
}, $developer
->getCompanies()));
$this->backend
->set($developer
->id(), $developer
->getCompanies(), CacheBackendInterface::CACHE_PERMANENT, $tags);
}
}
/**
* {@inheritdoc}
*/
public function remove(array $ids = []) : void {
if (empty($ids)) {
$this->backend
->invalidateAll();
}
else {
$this->backend
->invalidateMultiple($ids);
}
}
/**
* {@inheritdoc}
*/
public function invalidate(array $tags) : void {
$this->backend
->invalidateTags($tags);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeveloperCompaniesCache:: |
private | property | The memory cache backend. | |
DeveloperCompaniesCache:: |
public | function |
Returns companies of a developer. Overrides DeveloperCompaniesCacheInterface:: |
|
DeveloperCompaniesCache:: |
public | function |
Invalidates cache entries by tag. Overrides DeveloperCompaniesCacheInterface:: |
|
DeveloperCompaniesCache:: |
public | function |
Removes cached company information of a developer. Overrides DeveloperCompaniesCacheInterface:: |
|
DeveloperCompaniesCache:: |
public | function |
Saves developers' companies to cache. Overrides DeveloperCompaniesCacheInterface:: |
|
DeveloperCompaniesCache:: |
public | function | DeveloperCompaniesCache constructor. |