From e85e18dad801d97b77a75d76f098ad769346a403 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Sat, 18 May 2024 14:46:23 +0400 Subject: [PATCH] reintroduce 1 hour cache, remove servers to player cache due changes can happen fast. --- .../redisbungee/api/PlayerDataManager.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java index a867007..7f7d23f 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java @@ -37,12 +37,10 @@ import java.util.concurrent.TimeUnit; public abstract class PlayerDataManager { protected final RedisBungeePlugin

plugin; - private final LoadingCache serverCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getServerFromRedis); - private final LoadingCache lastServerCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getLastServerFromRedis); - private final LoadingCache proxyCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getProxyFromRedis); - private final LoadingCache ipCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getIpAddressFromRedis); - private final Object SERVERS_TO_PLAYERS_KEY = new Object(); - private final LoadingCache> serverToPlayersCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(this::serversToPlayersBuilder); + private final LoadingCache serverCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getServerFromRedis); + private final LoadingCache lastServerCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getLastServerFromRedis); + private final LoadingCache proxyCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getProxyFromRedis); + private final LoadingCache ipCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getIpAddressFromRedis); private final UnifiedJedis unifiedJedis; private final String proxyId; private final String networkId; @@ -229,11 +227,8 @@ public abstract class PlayerDataManager serversToPlayers() { - return this.serverToPlayersCache.get(SERVERS_TO_PLAYERS_KEY); - } - protected Multimap serversToPlayersBuilder(Object o) { + public Multimap serversToPlayers() { try { return new RedisPipelineTask>(plugin) { private final Set uuids = plugin.proxyDataManager().networkPlayers();