您的位置:首页 > 新闻 > 会展 > 外贸seo是什么意思啊_农村自建房室内装修设计效果图_安新seo优化排名网站_太原网络推广公司

外贸seo是什么意思啊_农村自建房室内装修设计效果图_安新seo优化排名网站_太原网络推广公司

2024/10/13 3:40:22 来源:https://blog.csdn.net/qq_40306697/article/details/142764722  浏览:    关键词:外贸seo是什么意思啊_农村自建房室内装修设计效果图_安新seo优化排名网站_太原网络推广公司
外贸seo是什么意思啊_农村自建房室内装修设计效果图_安新seo优化排名网站_太原网络推广公司

1、文件所在位置:
在这里插入图片描述
2、需要Guava依赖:

        <dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>23.0</version></dependency>

3、启动时就读取放入缓存的代码:

@Service
@AllArgsConstructor
@Slf4j
public class SensitiveCheckService {private static final Cache<String, String> SENSITIVE_WORDS_CACHE = CacheBuilder.newBuilder()// 设置缓存容量数.maximumSize(1).build();static {try {ClassLoader classLoader = DemoApplication.class.getClassLoader();Enumeration<URL> resources = classLoader.getResources("static/sensitive/敏感词库.txt");List<String> allSensitiveList = new ArrayList<>();while (resources.hasMoreElements()) {URL resource = resources.nextElement();BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream(), "utf-8"));String line;while ((line = reader.readLine()) != null) {// 一行行读取allSensitiveList.add(line);}SENSITIVE_WORDS_CACHE.put(RedisKeyConstant.ALL_SENSITIVE_WORDS, JSON.toJSONString(allSensitiveList));}} catch (Exception e) {log.error("加载敏感词失败", e);}}public List<String> getSensitiveWordsCache() {return JSON.parseArray(SENSITIVE_WORDS_CACHE.getIfPresent(RedisKeyConstant.ALL_SENSITIVE_WORDS), String.class);}}

Guava的缓存类似于redis。比起Redis,Guava的缓存优势在于更轻更快,而Redis的优势在于支持分布式

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com