Skip to content

Commit

Permalink
Disable cache while cache_expiration is set to 0 in Apigee Edge Teams (
Browse files Browse the repository at this point in the history
  • Loading branch information
phdhiren authored Apr 27, 2021
1 parent 408edd3 commit 3d269f9
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ public function __construct(CacheFactoryInterface $cache_factory, MemoryCacheFac
* {@inheritdoc}
*/
public function saveMembership(string $company, CompanyMembership $membership): void {
$expiration = $this->persistentCacheExpiration;

// Do not save in cache, if expiration is set to 0.
if (0 === $expiration) {
return;
}

// Tag company membership cache entries with members' (developers') email
// addresses for easier cache invalidation when a developer gets removed.
$tags = [];
foreach (array_keys($membership->getMembers()) as $developer_email) {
$tags[] = "developer:{$developer_email}";
}
$this->memoryCache->set($company, $membership, CacheBackendInterface::CACHE_PERMANENT, $tags);
$expiration = $this->persistentCacheExpiration;
if ($expiration !== CacheBackendInterface::CACHE_PERMANENT) {
$expiration = $this->systemTime->getCurrentTime() + $expiration;
}
Expand Down

0 comments on commit 3d269f9

Please sign in to comment.