dispose - 使用 Closeable 加载缓存
问题描述
使用 LoadingCache 时如何处理 Closeable 对象?
我是否需要保存对我在build
通话中的引用,并在创建新的之前关闭它?
private final LoadingCache<String, BigtableDataClient> DATA_CLIENT_LOADING_CACHE = CacheBuilder.newBuilder()
.refreshAfterWrite(50, TimeUnit.MINUTES)
.build(new CacheLoader<String, BigtableDataClient>() {
@Override
public BigtableDataClient load(final String key) {
... // in here?
}
解决方案
推荐阅读
- c++ - grpc helloworld 的 protoc 文件对于 64 位和 32 位是相同的。如果不能,请为 helloworld 发布 32 位协议文件
- google-sheets - 使用 Google 表格检查单元格 B 是否包含单元格 A 中的所有单词
- frida - Frida - 钩住 android 原生 C++ api
- excel - 查找表中最早的条目
- git - git filter-branch 如何影响用作子模块的 repos?
- java - 如何使用 JSSC 通过串行端口连接传递多种类型的数据?
- c++ - C++ 正则表达式从特定行获取 IP
- algorithm - 仅使用 90 度转弯和直线连接所有点
- excel - 从多个工作表中提取文本
- javascript - 这个弹窗搜索JavaScript如何添加自动关闭弹窗的代码?