mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-28 05:11:39 +08:00
39 lines
630 B
PHP
39 lines
630 B
PHP
<?php
|
|
|
|
namespace App\Caches;
|
|
|
|
use App\Repos\User as UserRepo;
|
|
|
|
class UserCounter extends Counter
|
|
{
|
|
|
|
protected $lifetime = 7 * 86400;
|
|
|
|
public function getLifetime()
|
|
{
|
|
return $this->lifetime;
|
|
}
|
|
|
|
public function getKey($id = null)
|
|
{
|
|
return "user_counter:{$id}";
|
|
}
|
|
|
|
public function getContent($id = null)
|
|
{
|
|
$userRepo = new UserRepo();
|
|
|
|
$user = $userRepo->findById($id);
|
|
|
|
if (!$user) return [];
|
|
|
|
$content = [
|
|
'notice_count' => $user->notice_count,
|
|
'msg_count' => $user->msg_count,
|
|
];
|
|
|
|
return $content;
|
|
}
|
|
|
|
}
|