1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 04:01:31 +08:00
course-tencent-cloud/app/Services/CourseIndexSyncer.php
2020-03-16 15:33:36 +08:00

47 lines
735 B
PHP

<?php
namespace App\Services;
use App\Library\Cache\Backend\Redis as RedisCache;
class CourseIndexSyncer extends Service
{
/**
* @var RedisCache
*/
protected $cache;
/**
* @var \Redis
*/
protected $redis;
/**
* @var int
*/
protected $lifetime = 86400;
public function __construct()
{
$this->cache = $this->getDI()->get('cache');
$this->redis = $this->cache->getRedis();
}
public function addItem($courseId)
{
$key = $this->getSyncKey();
$this->redis->sAdd($key, $courseId);
$this->redis->expire($key, $this->lifetime);
}
public function getSyncKey()
{
return 'course_index_sync';
}
}