src/Assistant.php
private function _keepKeys($tag)
    {
        $key = $this->normalizeTagForKey($tag);
        $items = array_unique($this->items[$tag]);

        // 存入缓存
        $this->manager->set($key, $items, 999999999);
        // 永久存入数据库
        try {
            Entity::updateOrCreate(
                ['key' => $key],
                ['items' => $items]
            );
        } catch (\Exception $e) {
            // 不做任何处理
            if ($this->manager->debug()) {
                throw $e;
            } else {
                $logger = $this->manager->logger();
                if ($logger) {
                    $logger->warning($e->getMessage(), ['tag' => $tag, 'key' => $key]);
                }
            }
        }

        return $this;
    }
private function _keepKeys($tag)
    {
        $key = $this->normalizeTagForKey($tag);
        $items = array_unique($this->items[$tag]);

        // 存入缓存
        $this->manager->set($key, $items, 999999999);
        // 永久存入数据库
        try {
            Entity::updateOrCreate(
                ['key' => $key],
                ['items' => $items]
            );
        } catch (\Exception $e) {
            // 不做任何处理
            if ($this->manager->debug()) {
                throw $e;
            } else {
                $logger = $this->manager->logger();
                if ($logger) {
                    $logger->warning($e->getMessage(), ['tag' => $tag, 'key' => $key]);
                }
            }
        }

        return $this;
    }
永久存储key.

@param string $tag 标签

@return static