chart handled 4
This commit is contained in:
@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
class ZaarboxPriceService
|
class ZaarboxPriceService
|
||||||
{
|
{
|
||||||
public const CACHE_KEY = 'zaarbox_gold_prices';
|
private const CACHE_KEY_PREFIX = 'zaarbox_gold_prices';
|
||||||
|
|
||||||
private const CACHE_TTL_MINUTES = 35;
|
private const CACHE_TTL_MINUTES = 35;
|
||||||
|
|
||||||
@@ -33,9 +33,14 @@ class ZaarboxPriceService
|
|||||||
return $chartId ?: self::HISTORY_ID;
|
return $chartId ?: self::HISTORY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function cacheKey(): string
|
||||||
|
{
|
||||||
|
return self::CACHE_KEY_PREFIX . ':' . $this->historyId();
|
||||||
|
}
|
||||||
|
|
||||||
public function getAllPrices(): array
|
public function getAllPrices(): array
|
||||||
{
|
{
|
||||||
$cached = Cache::get(self::CACHE_KEY);
|
$cached = Cache::get($this->cacheKey());
|
||||||
|
|
||||||
if (is_array($cached) && isset($cached['prices'])) {
|
if (is_array($cached) && isset($cached['prices'])) {
|
||||||
return $cached['prices'];
|
return $cached['prices'];
|
||||||
@@ -48,7 +53,7 @@ class ZaarboxPriceService
|
|||||||
{
|
{
|
||||||
$prices = $this->fetchAllPrices();
|
$prices = $this->fetchAllPrices();
|
||||||
|
|
||||||
Cache::put(self::CACHE_KEY, [
|
Cache::put($this->cacheKey(), [
|
||||||
'prices' => $prices,
|
'prices' => $prices,
|
||||||
'refreshed_at' => now()->toIso8601String(),
|
'refreshed_at' => now()->toIso8601String(),
|
||||||
], now()->addMinutes(self::CACHE_TTL_MINUTES));
|
], now()->addMinutes(self::CACHE_TTL_MINUTES));
|
||||||
|
|||||||
Reference in New Issue
Block a user