1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 04:07:17 +08:00
2020-09-17 21:29:29 +08:00

34 lines
510 B
PHP

<?php
namespace App\Services\Sync;
use App\Services\Service;
class UserIndex extends Service
{
/**
* @var int
*/
protected $lifetime = 86400;
public function addItem($userId)
{
$redis = $this->getRedis();
$key = $this->getSyncKey();
$redis->sAdd($key, $userId);
if ($redis->sCard($key) == 1) {
$redis->expire($key, $this->lifetime);
}
}
public function getSyncKey()
{
return 'sync_user_index';
}
}