Update dump cache immediately upon startup
This commit is contained in:
parent
c1017f9241
commit
043bc76cd3
@ -214,6 +214,7 @@ public final class APIv3 extends AbstractVerticle {
|
||||
Server.updateCache();
|
||||
ServerGroup.updateCache();
|
||||
EmailUtils.updateBannedEmailDomains();
|
||||
GETDumpsType.updateCache();
|
||||
}
|
||||
|
||||
private ObjectMapper createMongoJacksonMapper() {
|
||||
@ -244,7 +245,7 @@ public final class APIv3 extends AbstractVerticle {
|
||||
Router http = Router.router(vertx);
|
||||
|
||||
http.route().handler(LoggerHandler.create(LoggerFormat.TINY));
|
||||
http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(5)));
|
||||
http.route().handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(7)));
|
||||
http.route().method(HttpMethod.PUT).method(HttpMethod.POST).method(HttpMethod.DELETE).handler(BodyHandler.create());
|
||||
http.route().handler(new ActorAttributeHandler());
|
||||
http.route().handler(new MetricsHandler());
|
||||
|
@ -3,6 +3,7 @@ package net.frozenorb.apiv3.route;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.frozenorb.apiv3.APIv3;
|
||||
import net.frozenorb.apiv3.model.Grant;
|
||||
import net.frozenorb.apiv3.model.Punishment;
|
||||
@ -11,14 +12,18 @@ import net.frozenorb.apiv3.util.ErrorUtils;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public final class GETDumpsType implements Handler<RoutingContext> {
|
||||
|
||||
private List<UUID> banCache = new LinkedList<>();
|
||||
private List<UUID> blacklistCache = new LinkedList<>();
|
||||
private Map<String, List<UUID>> grantCache = new HashMap<>();
|
||||
private static List<UUID> banCache = new LinkedList<>();
|
||||
private static List<UUID> blacklistCache = new LinkedList<>();
|
||||
private static Map<String, List<UUID>> grantCache = new HashMap<>();
|
||||
|
||||
public GETDumpsType() {
|
||||
APIv3.getVertxInstance().setPeriodic(TimeUnit.MINUTES.toMillis(5), (id) -> {
|
||||
static {
|
||||
APIv3.getVertxInstance().setPeriodic(TimeUnit.MINUTES.toMillis(5), (id) -> updateCache());
|
||||
}
|
||||
|
||||
public static void updateCache() {
|
||||
Punishment.findByType(ImmutableSet.of(
|
||||
Punishment.PunishmentType.BAN,
|
||||
Punishment.PunishmentType.BLACKLIST
|
||||
@ -43,8 +48,8 @@ public final class GETDumpsType implements Handler<RoutingContext> {
|
||||
}
|
||||
}
|
||||
|
||||
GETDumpsType.this.banCache = banCache;
|
||||
GETDumpsType.this.blacklistCache = blacklistCache;
|
||||
GETDumpsType.banCache = banCache;
|
||||
GETDumpsType.blacklistCache = blacklistCache;
|
||||
});
|
||||
|
||||
Grant.findAll((grants, error) -> {
|
||||
@ -70,8 +75,7 @@ public final class GETDumpsType implements Handler<RoutingContext> {
|
||||
users.add(grant.getUser());
|
||||
}
|
||||
|
||||
GETDumpsType.this.grantCache = grantCache;
|
||||
});
|
||||
GETDumpsType.grantCache = grantCache;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user