Remove cache
This commit is contained in:
parent
06ce165bf8
commit
da5d87656f
1 changed files with 5 additions and 13 deletions
|
@ -1,17 +1,15 @@
|
||||||
package eu.m724.jarupdater.live;
|
package eu.m724.jarupdater.live;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
import eu.m724.jarupdater.environment.Environment;
|
import eu.m724.jarupdater.environment.Environment;
|
||||||
import eu.m724.jarupdater.object.Version;
|
import eu.m724.jarupdater.object.Version;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class MetadataFacade {
|
public class MetadataFacade {
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
private final MetadataDAO metadataDao;
|
private final MetadataDAO metadataDao;
|
||||||
|
|
||||||
private final HashMap<String, CompletableFuture<Version>> cache = new HashMap<>();
|
|
||||||
private CompletableFuture<List<String>> channels = null;
|
private CompletableFuture<List<String>> channels = null;
|
||||||
|
|
||||||
public MetadataFacade(Environment environment, MetadataDAO metadataDao) {
|
public MetadataFacade(Environment environment, MetadataDAO metadataDao) {
|
||||||
|
@ -35,13 +33,7 @@ public class MetadataFacade {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Version> getVersionMetadata(String version, boolean ignoreCache) {
|
public CompletableFuture<Version> getVersionMetadata(String version, boolean ignoreCache) {
|
||||||
if (!ignoreCache && cache.containsKey(version))
|
return metadataDao.getMetadata(environment.getChannel(), version);
|
||||||
return cache.get(version);
|
|
||||||
|
|
||||||
CompletableFuture<Version> future = metadataDao.getMetadata(environment.getChannel(), version);
|
|
||||||
cache.put(version, future); // TODO should we cache forever?
|
|
||||||
|
|
||||||
return future;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Version> getVersionMetadata(String version) {
|
public CompletableFuture<Version> getVersionMetadata(String version) {
|
||||||
|
|
Loading…
Reference in a new issue