close redis because no memory leaks around at anarchyfreedom

This commit is contained in:
spacerocket62 2020-10-27 14:21:57 -07:00
parent b8357b6d1d
commit ebcc9f2fcc

View File

@ -9,6 +9,7 @@ import me.totalfreedom.plex.config.Config;
import me.totalfreedom.plex.config.YamlConfig; import me.totalfreedom.plex.config.YamlConfig;
import me.totalfreedom.plex.listeners.PlayerListener; import me.totalfreedom.plex.listeners.PlayerListener;
import me.totalfreedom.plex.storage.MongoConnection; import me.totalfreedom.plex.storage.MongoConnection;
import me.totalfreedom.plex.storage.RedisConnection;
import me.totalfreedom.plex.storage.SQLConnection; import me.totalfreedom.plex.storage.SQLConnection;
import me.totalfreedom.plex.storage.StorageType; import me.totalfreedom.plex.storage.StorageType;
import me.totalfreedom.plex.util.PlexLog; import me.totalfreedom.plex.util.PlexLog;
@ -26,6 +27,7 @@ public class Plex extends JavaPlugin
private SQLConnection sqlConnection; private SQLConnection sqlConnection;
private MongoConnection mongoConnection; private MongoConnection mongoConnection;
private RedisConnection redisConnection;
private MongoPlayerData mongoPlayerData; private MongoPlayerData mongoPlayerData;
private SQLPlayerData sqlPlayerData; private SQLPlayerData sqlPlayerData;
@ -42,6 +44,14 @@ public class Plex extends JavaPlugin
sqlConnection = new SQLConnection(); sqlConnection = new SQLConnection();
mongoConnection = new MongoConnection(); mongoConnection = new MongoConnection();
redisConnection = new RedisConnection();
try {
redisConnection.openPool();
PlexLog.log("Successfully opened redis pool. Closing.");
} catch (Exception e) {
e.printStackTrace();
}
redisConnection.getJedis().close();
} }
@Override @Override
@ -63,6 +73,11 @@ public class Plex extends JavaPlugin
@Override @Override
public void onDisable() public void onDisable()
{ {
if (redisConnection.getJedis().isConnected())
{
PlexLog.log("Disabling Redis/Jedis. No memory leaks in this Anarchy server !");
redisConnection.getJedis().close();
}
} }
public static Plex get() { public static Plex get() {