make(SystemGroupDataServices::class); return $service->getConfigNameValue($config_name, $limit); } catch (\Exception) { return []; } }; try { $cacheName = $limit ? "data_{$config_name}_{$limit}" : "data_{$config_name}"; if ($isCaChe) return $callable(); return CacheService::redisHandler(self::getTag())->remember($cacheName, $callable, self::EXPIRE_TIME); } catch (\Throwable) { try { return $callable(); } catch (\Throwable) { return []; } } } /** * 根据id 获取单个值 * @param int $id * @param bool $isCaChe 是否读取缓存 * @return array */ public static function getDataNumber(int $id, bool $isCaChe = false): array { $callable = function () use ($id) { try { /** @var SystemGroupDataServices $service */ $service = app()->make(SystemGroupDataServices::class); $data = $service->getDateValue($id); if (is_object($data)) $data = $data->toArray(); return $data; } catch (\Exception) { return []; } }; try { $cacheName = "data_number_{$id}"; if ($isCaChe) return $callable(); return CacheService::redisHandler(self::getTag())->remember($cacheName, $callable, self::EXPIRE_TIME); } catch (\Throwable) { try { return $callable(); } catch (\Throwable) { return []; } } } /** * 清空配置缓存 * @return bool|void */ public static function clear() { try { return CacheService::redisHandler(self::getTag())->clear(); } catch (\Throwable $e) { \think\facade\Log::error('清空配置缓存失败:原因:' . $e->getMessage()); return false; } } }