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