
com.penglecode.common.redis.jedis.JedisTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis-ms-sentinel Show documentation
Show all versions of jedis-ms-sentinel Show documentation
commons is a little java tool to make your development easier in your work.
The newest version!
package com.penglecode.common.redis.jedis;
import redis.clients.util.Pool;
public class JedisTemplate {
private final Pool jedisPool;
public JedisTemplate(Pool jedisPool){
this.jedisPool = jedisPool;
}
protected I getResource(){
return jedisPool.getResource();
}
protected void returnResource(I jedis){
if(jedis != null){
jedisPool.returnResource(jedis);
}
}
public O execute(JedisCallback callback){
if(callback != null){
I jedis = null;
try {
jedis = getResource();
return callback.doInJedis(jedis);
} finally {
returnResource(jedis);
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy