counter = new CacheChapterCounter(); } public function incrUserCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hIncrBy($chapter->id, 'user_count'); $this->syncChapterCounter($chapter); } public function decrUserCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hDecrBy($chapter->id, 'user_count'); $this->syncChapterCounter($chapter); } public function incrConsultCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hIncrBy($chapter->id, 'consult_count'); $this->syncChapterCounter($chapter); } public function decrConsultCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hDecrBy($chapter->id, 'consult_count'); $this->syncChapterCounter($chapter); } public function incrLikeCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hIncrBy($chapter->id, 'like_count'); $this->syncChapterCounter($chapter); } public function decrLikeCount(Event $event, $source, ChapterModel $chapter) { $this->counter->hDecrBy($chapter->id, 'like_count'); $this->syncChapterCounter($chapter); } protected function syncChapterCounter(ChapterModel $chapter) { $syncer = new ChapterCounterSyncer(); $syncer->addItem($chapter->id); } }