From 5c32804114c3d9500bdf99412fe3d61ae0c78f3b Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Mon, 22 Apr 2024 20:57:56 -0400 Subject: [PATCH] Re-enable server cache --- .../java/me/braydon/mc/service/MojangService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/API/src/main/java/me/braydon/mc/service/MojangService.java b/API/src/main/java/me/braydon/mc/service/MojangService.java index 48bf3b3..1a3b830 100644 --- a/API/src/main/java/me/braydon/mc/service/MojangService.java +++ b/API/src/main/java/me/braydon/mc/service/MojangService.java @@ -431,11 +431,11 @@ public final class MojangService { } // Check the cache for the server -// Optional cached = minecraftServerCache.findById("%s-%s".formatted(platform.name(), lookupHostname)); -// if (cached.isPresent()) { // Respond with the cache if present -// log.info("Found server in cache: {}", hostname); -// return cached.get(); -// } + Optional cached = minecraftServerCache.findById("%s-%s".formatted(platform.name(), lookupHostname)); + if (cached.isPresent()) { // Respond with the cache if present + log.info("Found server in cache: {}", hostname); + return cached.get(); + } List records = new ArrayList<>(); // The resolved DNS records for the server SRVRecord srvRecord = platform == MinecraftServer.Platform.JAVA ? DNSUtils.resolveSRV(hostname) : null; // Resolve the SRV record @@ -467,7 +467,7 @@ public final class MojangService { ((JavaMinecraftServer) minecraftServer.getValue()).setMojangBanned(isServerBlocked(hostname)); } -// minecraftServerCache.save(minecraftServer); + minecraftServerCache.save(minecraftServer); log.info("Cached server: {}", hostname); minecraftServer.setCached(-1L); // Set to -1 to indicate it's not cached in the response return minecraftServer;