我使用 mapdb 的直接内存作为我的堆外内存。因为我的应用程序中有很多 sortedset,所以我使用 mapdb 树集缓存机制来存储我的值。
代码如下:
@PostConstruct
private void initDbEngine() {
try {
dbEngine = DBMaker
.memoryDirectDB()
.closeOnJvmShutdown()
.concurrencyScale(16)
.make();
logger.error("dbEngine init ok...");
} catch (Exception ex) {
logger.error(OffheapCacheConst.PACKAGE_CONTAINER, ex);
throw ex;
}
}
private SortedSet initSortedSetContainer(String containerName) {
try {
SortedSet sortedSet = dbEngine
.treeSet(containerName)
// why below three properties not exist????
//.expireAfterCreate(86400 * 30 * 12, TimeUnit.SECONDS)
//.expireAfterUpdate(86400 * 30 * 12, TimeUnit.SECONDS)
//.expireAfterGet(86400 * 30 * 12, TimeUnit.SECONDS)
.maxNodeSize(16)
.createOrOpen();
return sortedSet;
} catch (Exception ex) {
logger.error(OffheapCacheConst.PACKAGE_CONTAINER, ex);
throw ex;
}
}
但是当我试图找到 时expireAfterCreate/expireAfterUpdate/expireAfterGet property
,我什么也没有。只是想知道,为什么 treeset 没有附加这些属性?
还有更多想法可以使用 mapdb 的树集进行密钥过期吗?