diff --git a/core/src/main/java/org/elasticsearch/common/cache/Cache.java b/core/src/main/java/org/elasticsearch/common/cache/Cache.java index 962ab2f536b..373b32aa7a5 100644 --- a/core/src/main/java/org/elasticsearch/common/cache/Cache.java +++ b/core/src/main/java/org/elasticsearch/common/cache/Cache.java @@ -117,7 +117,7 @@ public class Cache { */ protected long now() { // System.nanoTime takes non-negligible time, so we only use it if we need it - return expireAfterAccess == -1 ? 0 : System.nanoTime(); + return expireAfterWrite != -1 || expireAfterAccess != -1 ? System.nanoTime() : 0; } public void setExpireAfterWrite(long expireAfterWrite) {