protected function updateKeywordIndex($key)
    {
        $this->setKeywordsOperation(true);

        $keywordsState = $this->determineKeywordsState($key);

        foreach (array_merge($keywordsState['new'], $keywordsState['obsolete']) as $keyword) {
            $indexKey = $this->generateIndexKey($keyword);
            $oldIndex = parent::pull($indexKey, []);
            $newIndex = in_array($keyword, $keywordsState['obsolete']) ?
                array_values(array_diff($oldIndex, [$key])) :
                array_values(array_unique(array_merge($oldIndex, [$key])));

            if (! empty($newIndex)) {
                parent::forever($indexKey, $newIndex);
            }
        }

        $this->setKeywordsOperation(false);
    }