mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-02 07:04:56 +08:00
36 lines
560 B
PHP
36 lines
560 B
PHP
<?php
|
|
|
|
namespace App\Caches;
|
|
|
|
use App\Repos\Category as CategoryRepo;
|
|
|
|
class Category extends Cache
|
|
{
|
|
|
|
protected $lifetime = 365 * 86400;
|
|
|
|
public function getLifetime()
|
|
{
|
|
return $this->lifetime;
|
|
}
|
|
|
|
public function getKey($id = null)
|
|
{
|
|
return "category:{$id}";
|
|
}
|
|
|
|
public function getContent($id = null)
|
|
{
|
|
$categoryRepo = new CategoryRepo();
|
|
|
|
$category = $categoryRepo->findById($id);
|
|
|
|
if (!$category) {
|
|
return new \stdClass();
|
|
}
|
|
|
|
return $category;
|
|
}
|
|
|
|
}
|