mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
Fix isStale condition
This commit is contained in:
parent
8bb15132d2
commit
c6cd09b50d
@ -63,7 +63,7 @@ public class Cache {
|
||||
Element element = null;
|
||||
try {
|
||||
element = cache.get(key);
|
||||
if (!condition.test(element)) {
|
||||
if (element != null && !condition.test(element)) {
|
||||
return getElementValue(element);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -77,7 +77,7 @@ public class Cache {
|
||||
}
|
||||
|
||||
public Object computeIfAbsent(Object key, Compute<?> compute) throws Exception {
|
||||
return computeIf(key, isAbsent(), compute);
|
||||
return computeIf(key, it -> it == null, compute);
|
||||
}
|
||||
|
||||
public void put(Object key, Object value) {
|
||||
@ -112,12 +112,8 @@ public class Cache {
|
||||
}
|
||||
}
|
||||
|
||||
public static Predicate<Element> isAbsent() {
|
||||
return (element) -> element == null;
|
||||
}
|
||||
|
||||
public static Predicate<Element> isStale(Duration expirationTime) {
|
||||
return (element) -> element == null || element.getObjectValue() == null || System.currentTimeMillis() - element.getLatestOfCreationAndUpdateTime() < expirationTime.toMillis();
|
||||
return (element) -> System.currentTimeMillis() - element.getLatestOfCreationAndUpdateTime() > expirationTime.toMillis();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
|
@ -9,7 +9,6 @@ import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user