admin管理员组文章数量:1278978
micronaut:
application:
name: isac-card
cache:
redis:
enabled: false
caffeine:
enabled: true
caches:
keyConfig:
maximum-size: 1000
expire-after-write: 2s
expire-after-write in micronaut is not getting expired after the set time.
@Test
void testCacheExpiry() {
System.out.println("First Call: " + cacheService.getValue()); // Fetches from AWS
System.out.println("Second Call: " + cacheService.getValue()); // Should be cached
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println("After 3s: " + cacheService.getValue());
cacheService.invalidateValue();
}
here is my service code
@Cacheable(value = "keyConfig")
public String getValue() {
// fetch from db
return value
}
@CacheInvalidate("keyConfig")
public void invalidateValue() {
System.out.println("Invalidating cache...");
}
But when i tried invalidateValue that is working. It invalidate the cache but expiry is not working after 3 sec also value is fetched from cache. Here is the log,
Value found in cache [keyConfig] for invocation: String getValue()
this is after calling invalidateValue
Value not found in cache for invocation: String getValue()
本文标签: javaMicronaut caffeine cache expiry is not workingStack Overflow
版权声明:本文标题:java - Micronaut caffeine cache expiry is not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741263413a2368029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论