2022-07-06 19:04:09 +00:00
|
|
|
package com.imaginarycode.minecraft.redisbungee.internal.summoners;
|
2022-04-14 10:12:47 +00:00
|
|
|
|
|
|
|
import redis.clients.jedis.Jedis;
|
2022-04-14 10:34:56 +00:00
|
|
|
import redis.clients.jedis.JedisPool;
|
2022-04-14 10:12:47 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
import java.io.IOException;
|
2022-07-06 19:04:09 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
public class JedisSummoner implements Summoner<Jedis> {
|
2022-04-14 10:12:47 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
private final JedisPool jedisPool;
|
2022-04-14 10:12:47 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
public JedisSummoner(JedisPool jedisPool) {
|
|
|
|
this.jedisPool = jedisPool;
|
|
|
|
}
|
2022-04-14 10:12:47 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
@Override
|
|
|
|
public Jedis obtainResource() {
|
|
|
|
return jedisPool.getResource();
|
|
|
|
}
|
2022-04-14 10:12:47 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
public JedisPool getJedisPool() {
|
|
|
|
return this.jedisPool;
|
|
|
|
}
|
2022-07-15 22:58:48 +00:00
|
|
|
|
2022-07-16 05:18:33 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAvailable() {
|
|
|
|
return !jedisPool.isClosed();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void close() throws IOException {
|
|
|
|
this.jedisPool.close();
|
|
|
|
|
|
|
|
}
|
2022-04-14 10:12:47 +00:00
|
|
|
}
|