cache = $this->getDI()->get('cache'); $this->redis = $this->cache->getRedis(); } public function addItem($userId) { $key = $this->getSyncKey(); $this->redis->sAdd($key, $userId); if ($this->redis->sCard($key) == 1) { $this->redis->expire($key, $this->lifetime); } } public function getSyncKey() { return 'sync_user_index'; } }