1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 20:52:44 +08:00
course-tencent-cloud/app/Caches/CommentCounter.php
2020-04-23 19:52:46 +08:00

38 lines
691 B
PHP

<?php
namespace App\Caches;
use App\Repos\Comment as CommentRepo;
class CommentCounter extends Counter
{
protected $lifetime = 1 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return "comment_counter:{$id}";
}
public function getContent($id = null)
{
$commentRepo = new CommentRepo();
$comment = $commentRepo->findById($id);
if (!$comment) return null;
return [
'reply_count' => $comment->reply_count,
'agree_count' => $comment->agree_count,
'oppose_count' => $comment->oppose_count,
];
}
}