perf: 优化用户在线状态

This commit is contained in:
kuaifan
2024-11-18 13:30:45 +08:00
parent 11ea2d3697
commit 42c77db1d4
4 changed files with 87 additions and 100 deletions

View File

@@ -6,6 +6,7 @@ namespace App\Models;
use App\Exceptions\ApiException;
use App\Module\Base;
use App\Module\Doo;
use App\Module\Table\OnlineData;
use App\Services\RequestContext;
use Cache;
use Carbon\Carbon;
@@ -195,7 +196,7 @@ class User extends AbstractModel
*/
public function getOnlineStatus()
{
$online = $this->bot || Cache::get("User::online:" . $this->userid) === "on";
$online = $this->bot || OnlineData::live($this->userid) > 0;
if ($online) {
return true;
}