简体   繁体   中英

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.

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? 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. This applies to refresh as well, as it is a form of eviction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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