2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-04-08 08:00:26 +00:00

Better server caching.

This commit is contained in:
Tux
2014-08-09 23:57:57 -04:00
parent d3b2f3f10b
commit 6df0a481e7
2 changed files with 12 additions and 7 deletions

View File

@@ -22,7 +22,6 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
/**
@@ -40,7 +39,6 @@ public class DataManager implements Listener {
* Most of these are purged only based on size limits but are also invalidated on certain actions.
*/
private final Cache<UUID, String> serverCache = CacheBuilder.newBuilder()
.expireAfterWrite(5, TimeUnit.SECONDS)
.maximumSize(2000)
.concurrencyLevel(2)
.build();
@@ -244,8 +242,12 @@ public class DataManager implements Listener {
if (message.getSource().equals(source))
return;
// For now we will just invalidate the caches. In a future version the action scope will be expanded ;)
invalidate(message.getTarget());
// For now we will just invalidate the caches, depending on what action occurred.
if (message.getAction() == DataManagerMessage.Action.SERVER_CHANGE) {
serverCache.invalidate(message.getTarget());
} else {
invalidate(message.getTarget());
}
}
@Getter
@@ -253,7 +255,8 @@ public class DataManager implements Listener {
static class DataManagerMessage {
enum Action {
JOIN,
LEAVE
LEAVE,
SERVER_CHANGE
}
private final UUID target;