diff --git a/.env.example b/.env.example index 4f0fede7..c54041eb 100755 --- a/.env.example +++ b/.env.example @@ -14,7 +14,7 @@ DB_USERNAME=root DB_PASSWORD=123456 BROADCAST_DRIVER=log -CACHE_DRIVER=file +CACHE_DRIVER=redis QUEUE_CONNECTION=redis SESSION_DRIVER=redis SESSION_LIFETIME=120 diff --git a/app/Services/StatisticalService.php b/app/Services/StatisticalService.php index d403912f..328f2045 100644 --- a/app/Services/StatisticalService.php +++ b/app/Services/StatisticalService.php @@ -30,7 +30,7 @@ class StatisticalService { } public function setServerStats() { - $this->serverStats = Cache::get("stat_server_{$this->startAt}"); + $this->serverStats = Cache::store('file')->get("stat_server_{$this->startAt}"); $this->serverStats = json_decode($this->serverStats, true) ?? []; if (!is_array($this->serverStats)) { $this->serverStats = []; @@ -38,7 +38,7 @@ class StatisticalService { } public function setUserStats() { - $this->userStats = Cache::get("stat_user_{$this->startAt}"); + $this->userStats = Cache::store('file')->get("stat_user_{$this->startAt}"); $this->userStats = json_decode($this->userStats, true) ?? []; if (!is_array($this->userStats)) { $this->userStats = []; @@ -95,7 +95,7 @@ class StatisticalService { } else { $this->serverStats[$serverType][$serverId] = [$u, $d]; } - Cache::set("stat_server_{$this->startAt}", json_encode($this->serverStats)); + Cache::store('file')->set("stat_server_{$this->startAt}", json_encode($this->serverStats)); } public function statUser($rate, $userId, $u, $d) @@ -107,7 +107,7 @@ class StatisticalService { } else { $this->userStats[$rate][$userId] = [$u, $d]; } - Cache::set("stat_user_{$this->startAt}", json_encode($this->userStats)); + Cache::store('file')->set("stat_user_{$this->startAt}", json_encode($this->userStats)); } public function getStatUserByUserID($userId): array @@ -165,12 +165,12 @@ class StatisticalService { public function clearStatUser() { - Cache::forget("stat_user_{$this->startAt}"); + Cache::store('file')->forget("stat_user_{$this->startAt}"); } public function clearStatServer() { - Cache::forget("stat_server_{$this->startAt}"); + Cache::store('file')->forget("stat_server_{$this->startAt}"); } public function getStatRecord($type)