简体   繁体   English

在番石榴缓存中,在不提供它的情况下创建 LoadingCache 时,refreshAfterWrite 的默认值是什么

[英]In Guava cache what is the default value for refreshAfterWrite when creating a LoadingCache without providing it

What is the default value for refreshAfterWrite when creating a LoadingCache without providing it.在不提供的情况下创建 LoadingCache 时,refreshAfterWrite 的默认值是多少。

cache = CacheBuilder.newBuilder().build(new CacheLoader<Object, Object>() {
  @Override
  public Object load(Object o) throws Exception {
    return getObj(o);
  }

  @Override
  public ListenableFuture<Object> reload(Object o) throws Exception {
    final ListenableFutureTask<Object> task = ListenableFutureTask.create(() -> {
      return getObj(o);
    });
    executor.execute(task);
    return task;
  }
});

I see in the debug that the refreshAfterWrite is -1, but what does it means?我在调试中看到 refreshAfterWrite 为 -1,但这意味着什么? It means it will never reload?这意味着它永远不会重新加载?

I can read from this issue that:我可以从这个问题中读到:

It's documented that if no options are set, a cache created by CacheBuilder will never do any kind of eviction.据记载,如果未设置任何选项,则 CacheBuilder 创建的缓存将永远不会执行任何类型的驱逐。 This applies to refresh as well, as it is a form of eviction.这也适用于刷新,因为它是一种驱逐形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM