From 14ca3b637762b9d461b9ea4cd775c8455c21ad9d Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Wed, 26 Feb 2025 10:53:06 +0800 Subject: [PATCH] feat : site cache --- app/Cache/Redis/Api/SiteCache.php | 6 +++++- app/Service/Api/Good/OptionalListService.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Cache/Redis/Api/SiteCache.php b/app/Cache/Redis/Api/SiteCache.php index 1ce6c6b..2dcf608 100644 --- a/app/Cache/Redis/Api/SiteCache.php +++ b/app/Cache/Redis/Api/SiteCache.php @@ -60,8 +60,12 @@ class SiteCache $siteKey = CommonRedisKey::siteListKey(); - $siteList = json_decode($this->redis->get($siteKey), true); + $siteListJsonDecode = json_decode($this->redis->get($siteKey,RedisCode::SYSTEM_DB), true); + if (empty($siteListJsonDecode)) return null; + $siteList = array_column($siteListJsonDecode, null, 'id'); + + unset($siteListJsonDecode); return $siteList[$siteId] ?? null; } } \ No newline at end of file diff --git a/app/Service/Api/Good/OptionalListService.php b/app/Service/Api/Good/OptionalListService.php index caf6365..98b48f2 100644 --- a/app/Service/Api/Good/OptionalListService.php +++ b/app/Service/Api/Good/OptionalListService.php @@ -43,7 +43,7 @@ class OptionalListService extends BaseService { $cycleId = $this->initTodayCycleId(); - if (empty($cycleId)) return ['list' => []]; + if (empty($cycleId)) return $this->return->success('success', ['list' => []]); $this->goodCache->cycleId = (int)$cycleId; $siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));