mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 11:41:27 +08:00
34 lines
518 B
PHP
34 lines
518 B
PHP
<?php
|
|
|
|
namespace App\Services\Sync;
|
|
|
|
use App\Services\Service;
|
|
|
|
class CourseIndex extends Service
|
|
{
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
protected $lifetime = 86400;
|
|
|
|
public function addItem($courseId)
|
|
{
|
|
$redis = $this->getRedis();
|
|
|
|
$key = $this->getSyncKey();
|
|
|
|
$redis->sAdd($key, $courseId);
|
|
|
|
if ($redis->sCard($key) == 1) {
|
|
$redis->expire($key, $this->lifetime);
|
|
}
|
|
}
|
|
|
|
public function getSyncKey()
|
|
{
|
|
return 'sync_course_index';
|
|
}
|
|
|
|
}
|