2

I use next one for my custom cache manager:

SimpleCacheManager cacheManager = new SimpleCacheManager();
GuavaCache myCache = new GuavaCache("telescope", CacheBuilder.newBuilder()
                .expireAfterWrite(5, TimeUnit.MINUTES).build());
cacheManager.setCaches(Arrays.asList(myCache));
return cacheManager;

Now I want to use LoadingCache, because I need the method refreshAfterWrite(5, TimeUnit.MINUTES) instead of expireAfterWrite(5, TimeUnit.MINUTES).

I can't put LoadingCache to GuavaCache and then set this GuavaCache into SimpleCacheManager.

Which implementations I need to use?

Derz0st
  • 21
  • 2
  • Why can't you pass a `LoadingCache` to `GuavaCache`? A quick read of `GuavaCache`'s [javadoc] states it takes a `com.google.common.cache.Cache` which `LoadingCache` extends. – Daniel Bickler Jun 09 '17 at 18:11
  • Use CaffeinCache instead of GuavaCache. You can set them in the cache manager and also have a refreshAfterWrite with those. – Crusaderpyro Oct 25 '18 at 11:08

0 Answers0