Fix server caching not taking platform into account
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0) (push) Successful in 1m0s

This commit is contained in:
Braydon 2024-04-08 23:39:57 -04:00
parent 7f19304b9e
commit 6b1465e29f
2 changed files with 4 additions and 4 deletions

@ -690,9 +690,9 @@ import java.io.Serializable;
@RedisHash(value = "server", timeToLive = 60L) // 1 minute (in seconds) @RedisHash(value = "server", timeToLive = 60L) // 1 minute (in seconds)
public final class CachedMinecraftServer implements Serializable { public final class CachedMinecraftServer implements Serializable {
/** /**
* The hostname of the cached server. * The id of this cached server.
*/ */
@Id @NonNull private transient final String hostname; @Id @NonNull private transient final String id;
/** /**
* The cached server. * The cached server.

@ -1007,7 +1007,7 @@ public final class MojangService {
String lookupHostname = hostname; // The hostname used to lookup the server String lookupHostname = hostname; // The hostname used to lookup the server
// Check the cache for the server // Check the cache for the server
Optional<CachedMinecraftServer> cached = minecraftServerCache.findById(hostname); Optional<CachedMinecraftServer> cached = minecraftServerCache.findById(platform.name() + "-" + hostname);
if (cached.isPresent()) { // Respond with the cache if present if (cached.isPresent()) { // Respond with the cache if present
log.info("Found server in cache: {}", hostname); log.info("Found server in cache: {}", hostname);
return cached.get(); return cached.get();
@ -1021,7 +1021,7 @@ public final class MojangService {
} }
// Build our server model, cache it, and then return it // Build our server model, cache it, and then return it
CachedMinecraftServer minecraftServer = new CachedMinecraftServer( CachedMinecraftServer minecraftServer = new CachedMinecraftServer(
lookupHostname, platform.name() + "-" + lookupHostname,
platform.getPinger().ping(hostname, port), platform.getPinger().ping(hostname, port),
System.currentTimeMillis() System.currentTimeMillis()
); );