1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-26 04:21:27 +08:00
course-tencent-cloud/app/Caches/ChapterCounter.php
2020-01-30 16:51:10 +08:00

41 lines
771 B
PHP

<?php
namespace App\Caches;
use App\Repos\Chapter as ChapterRepo;
class ChapterCounter extends Counter
{
protected $lifetime = 7 * 86400;
public function getLifetime()
{
return $this->lifetime;
}
public function getKey($id = null)
{
return "chapter_counter:{$id}";
}
public function getContent($id = null)
{
$chapterRepo = new ChapterRepo();
$chapter = $chapterRepo->findById($id);
if (!$chapter) return [];
$content = [
'lesson_count' => $chapter->lesson_count,
'user_count' => $chapter->user_count,
'comment_count' => $chapter->comment_count,
'like_count' => $chapter->like_count,
];
return $content;
}
}