Skip to content

Commit

Permalink
cache key fix
Browse files Browse the repository at this point in the history
  • Loading branch information
krzGablo committed Jun 20, 2024
1 parent 25734c6 commit 2417203
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Model/ApiFacade/Transaction/TransactionApiFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class TransactionApiFacade
{
private const CHANNELS_CACHE_KEY = 'tpay_channels';
private const CACHE_LIFETIME = 86400;

/** @var TransactionOriginApi */
Expand Down Expand Up @@ -75,7 +74,9 @@ public function channels(): array
return [];
}

$channels = $this->cache->load(self::CHANNELS_CACHE_KEY);
$cacheKey = 'tpay_channels'.md5(join('|', [$this->tpay->getOpenApiClientId(), $this->tpay->getOpenApiPassword(), !$this->tpay->useSandboxMode()]));

$channels = $this->cache->load($cacheKey);

if ($channels) {
return unserialize($channels);
Expand All @@ -85,7 +86,7 @@ public function channels(): array
return true === $channel->available;
});

$this->cache->save(serialize($channels), self::CHANNELS_CACHE_KEY, [], self::CACHE_LIFETIME);
$this->cache->save(serialize($channels), $cacheKey, [], self::CACHE_LIFETIME);

return $channels;
}
Expand Down

0 comments on commit 2417203

Please sign in to comment.