diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java index 691d154..ff21939 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/JedisConstants.java @@ -6,4 +6,5 @@ package zone.themcgamer.data.jedis; public class JedisConstants { public static final String HOST = "172.18.0.1"; public static final String AUTH = "CWhsuGvpYPhZt7ru"; + public static final int SELECTED_DB = 0; } \ No newline at end of file diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java index 244bb24..1a76235 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/cache/CacheRepository.java @@ -53,6 +53,7 @@ public class CacheRepository extends RedisRepository> { List> cached = new ArrayList<>(); try (Jedis jedis = getController().getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); for (ItemCacheType cacheType : ItemCacheType.values()) { for (String key : jedis.keys(cacheType.getIdentifier() + ":*")) { Map map = jedis.hgetAll(key); diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java index cb37724..e9a6925 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/command/JedisCommandHandler.java @@ -35,6 +35,7 @@ public class JedisCommandHandler { new Thread(() -> { try (Jedis jedis = pool.getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.psubscribe(new JedisPubSub() { @Override public void onPMessage(String pattern, String channel, String message) { @@ -80,6 +81,7 @@ public class JedisCommandHandler { System.out.println("Dispatching Redis command for class \"" + className + "\" with json \"" + json + "\""); try (Jedis jedis = pool.getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.publish("mcGamerZone:commands:" + className, json); } } diff --git a/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java b/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java index e681098..4785f52 100644 --- a/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java +++ b/serverdata/src/main/java/zone/themcgamer/data/jedis/repository/RedisRepository.java @@ -113,6 +113,7 @@ public abstract class RedisRepository { map.put(entry.getKey(), entry.getValue().toString()); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.hmset(key, map); long expiration = getExpiration(t); @@ -133,6 +134,7 @@ public abstract class RedisRepository { throw new IllegalArgumentException("Cannot remove, the key is null or empty: \"" + (key == null ? "null" : key) + "\""); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); jedis.del(key); } } @@ -147,6 +149,7 @@ public abstract class RedisRepository { List cached = new ArrayList<>(); try (Jedis jedis = controller.getPool().getResource()) { jedis.auth(JedisConstants.AUTH); + jedis.select(JedisConstants.SELECTED_DB); Set keys = jedis.keys(pattern); for (String key : keys) { Map data = jedis.hgetAll(key);