mirror of
https://github.com/plexusorg/Plex.git
synced 2024-11-16 16:46:11 +00:00
33 lines
1012 B
Java
33 lines
1012 B
Java
|
package me.totalfreedom.plex.storage;
|
||
|
|
||
|
import me.totalfreedom.plex.Plex;
|
||
|
import redis.clients.jedis.Jedis;
|
||
|
import redis.clients.jedis.JedisPool;
|
||
|
import redis.clients.jedis.JedisPoolConfig;
|
||
|
|
||
|
public class RedisConnection
|
||
|
{
|
||
|
private JedisPool pool;
|
||
|
private Jedis jedis;
|
||
|
|
||
|
public JedisPool openPool()
|
||
|
{
|
||
|
ClassLoader previous = Thread.currentThread().getContextClassLoader();
|
||
|
Thread.currentThread().setContextClassLoader(RedisConnection.class.getClassLoader());
|
||
|
this.pool = new JedisPool(new JedisPoolConfig(), Plex.get().getConfig().getString("data.side.hostname"), Plex.get().getConfig().getInt("data.side.port"));
|
||
|
Thread.currentThread().setContextClassLoader(previous);
|
||
|
return pool;
|
||
|
}
|
||
|
|
||
|
public Jedis getJedis()
|
||
|
{
|
||
|
this.jedis = pool.getResource();
|
||
|
if (Plex.get().getConfig().getBoolean("data.side.auth"))
|
||
|
{
|
||
|
jedis.auth(Plex.get().getConfig().getString("data.side.password"));
|
||
|
}
|
||
|
return jedis;
|
||
|
}
|
||
|
|
||
|
}
|