update: stat service

This commit is contained in:
v2board 2023-06-05 14:10:14 +08:00
parent b39299be23
commit 948177f22e
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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)