@PostConstruct
    public void initLocalCache() {
        if (!ENABLED) {
            return;
        }

        // 第一步：查询数据
        List<SensitiveWordDO> sensitiveWords = sensitiveWordMapper.selectList();
        log.info("[initLocalCache][缓存敏感词，数量为:{}]", sensitiveWords.size());

        // 第二步：构建缓存
        // 写入 sensitiveWordTagsCache 缓存
        Set<String> tags = new HashSet<>();
        sensitiveWords.forEach(word -> tags.addAll(word.getTags()));
        sensitiveWordTagsCache = tags;
        sensitiveWordCache = sensitiveWords;
        // 写入 defaultSensitiveWordTrie、tagSensitiveWordTries 缓存
        initSensitiveWordTrie(sensitiveWords);
    }
@Test
    public void testInitLocalCache() {
        SensitiveWordDO wordDO1 = randomPojo(SensitiveWordDO.class, o -> o.setName("傻瓜")
                .setTags(singletonList("论坛")).setStatus(CommonStatusEnum.ENABLE.getStatus()));
        sensitiveWordMapper.insert(wordDO1);
        SensitiveWordDO wordDO2 = randomPojo(SensitiveWordDO.class, o -> o.setName("笨蛋")
                .setTags(singletonList("蔬菜")).setStatus(CommonStatusEnum.ENABLE.getStatus()));
        sensitiveWordMapper.insert(wordDO2);
        SensitiveWordDO wordDO3 = randomPojo(SensitiveWordDO.class, o -> o.setName("白")
                .setTags(singletonList("测试")).setStatus(CommonStatusEnum.ENABLE.getStatus()));
        sensitiveWordMapper.insert(wordDO3);
        SensitiveWordDO wordDO4 = randomPojo(SensitiveWordDO.class, o -> o.setName("白痴")
                .setTags(singletonList("测试")).setStatus(CommonStatusEnum.ENABLE.getStatus()));
        sensitiveWordMapper.insert(wordDO4);

        // 调用
        sensitiveWordService.initLocalCache();
        // 断言 sensitiveWordTagsCache 缓存
        assertEquals(SetUtils.asSet("论坛", "蔬菜", "测试"), sensitiveWordService.getSensitiveWordTagSet());
        // 断言 sensitiveWordCache
        assertEquals(4, sensitiveWordService.getSensitiveWordCache().size());
        assertPojoEquals(wordDO1, sensitiveWordService.getSensitiveWordCache().get(0));
        assertPojoEquals(wordDO2, sensitiveWordService.getSensitiveWordCache().get(1));
        assertPojoEquals(wordDO3, sensitiveWordService.getSensitiveWordCache().get(2));
        // 断言 tagSensitiveWordTries 缓存
        assertNotNull(sensitiveWordService.getDefaultSensitiveWordTrie());
        assertEquals(3, sensitiveWordService.getTagSensitiveWordTries().size());
        assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("论坛"));
        assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("蔬菜"));
        assertNotNull(sensitiveWordService.getTagSensitiveWordTries().get("测试"));
    }