From ceefd20ed94e307f90e99883054edcd45a98c7c3 Mon Sep 17 00:00:00 2001 From: Ivan Stasiuk Date: Thu, 22 Feb 2024 22:01:46 +0000 Subject: [PATCH] fix: less cache --- src/Client.php | 3 +-- tests/GetAuthTokenTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index 3801909..7393338 100644 --- a/src/Client.php +++ b/src/Client.php @@ -41,7 +41,6 @@ class Client implements HttpClientInterface, HasSourceModelInterface private ConfigInterface $config; private CacheInterface $cache; - private int $ttlMarginInSeconds = 60; public function __construct(ConfigInterface $config, ClientInterface $httpClient, CacheInterface $cache) { @@ -82,7 +81,7 @@ public function getAuthToken(): string $this->cache->set( $this->authTokenCacheKey(), $response->token, - $expiresAt->subSeconds($this->ttlMarginInSeconds)->diffInSeconds(Carbon::now()) + $expiresAt->diffInSeconds(Carbon::now()) / 2 ); return $response->token; diff --git a/tests/GetAuthTokenTest.php b/tests/GetAuthTokenTest.php index 45e46e6..3711e07 100644 --- a/tests/GetAuthTokenTest.php +++ b/tests/GetAuthTokenTest.php @@ -65,7 +65,7 @@ public function it_can_cache_and_return_auth_token() ->with( $api->authTokenCacheKey(), $this->tokenValue, - 3600 - 60 + 1800 ); }