1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

grace period to make sure data is always fresh when TTL is almost about to be reached

This commit is contained in:
Reinhard Pointner 2016-03-24 07:56:43 +00:00
parent eb25b1e1b3
commit 0304a12b76
2 changed files with 9 additions and 8 deletions

View File

@ -12,16 +12,17 @@ import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import org.w3c.dom.Document;
import net.filebot.CachedResource.Transform;
import net.sf.ehcache.Element;
import org.w3c.dom.Document;
public class Cache {
public static final Duration ONE_DAY = Duration.ofDays(1);
public static final Duration ONE_WEEK = Duration.ofDays(7);
public static final Duration ONE_MONTH = Duration.ofDays(30);
// grace period to make sure data is always fresh when TTL is almost about to be reached
public static final Duration ONE_DAY = Duration.ofHours(18);
public static final Duration ONE_WEEK = Duration.ofDays(6);
public static final Duration ONE_MONTH = Duration.ofDays(24);
public static Cache getCache(String name, CacheType type) {
return CacheManager.getInstance().getCache(name.toLowerCase() + "_" + type.ordinal(), type);

View File

@ -12,15 +12,15 @@ public enum CacheType {
Weekly(Duration.ofDays(12), true),
Daily(Duration.ofHours(24), true),
Daily(Duration.ofHours(18), true),
Ephemeral(Duration.ofHours(6), false);
Ephemeral(Duration.ofHours(2), false);
final long timeToLiveSeconds;
final boolean diskPersistent;
CacheType(Duration timeToLive, boolean diskPersistent) {
this.timeToLiveSeconds = timeToLive.minusHours(1).getSeconds(); // 60 minutes grace period to make sure data is always fresh when TTL is almost about to be exceeded
this.timeToLiveSeconds = timeToLive.getSeconds();
this.diskPersistent = diskPersistent;
}