1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 12:05:39 +08:00
course-tencent-cloud/app/Services/CourseCacheSyncer.php
2020-01-30 16:51:10 +08:00

42 lines
675 B
PHP

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