1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 21:31:37 +08:00
2020-04-23 19:52:46 +08:00

48 lines
762 B
PHP

<?php
namespace App\Services\Syncer;
use App\Library\Cache\Backend\Redis as RedisCache;
use App\Services\Service;
class CourseIndex 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';
}
}