redis->exists($siteKey) && $this->redis->exists($LngLatKey)) return; $siteList = $this->siteModel->getAllSiteList(); $this->redis->delete($siteKey); $this->redis->delete($LngLatKey); foreach ($siteList as $site) { $this->redis->geoAdd($LngLatKey, $site['lng'],$site['lat'],$site['id'],RedisCode::SYSTEM_DB); } $this->redis->set($siteKey,json_encode(array_column($siteList, null, 'id'), JSON_UNESCAPED_UNICODE),RedisCode::SYSTEM_DB); } /** * @param int $siteId * @return array|null * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function getSiteInfo(int $siteId): array|null { $this->setSiteRedis(); $siteKey = CommonRedisKey::siteListKey(); $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; } }