use of redis.clients.jedis.ShardedJedis in project blog by liqianggh.
the class RedisShardedPoolUtil method setNx.
// setNx方法
public static Long setNx(String key, String value) {
ShardedJedis jedis = null;
Long result = null;
try {
jedis = RedisShardedPool.getJedis();
result = jedis.setnx(key, value);
} catch (Exception e) {
log.error("set key:{} value:{} error", key, value, e);
RedisShardedPool.returnBrokenResource(jedis);
return result;
}
RedisShardedPool.returnResource(jedis);
return result;
}
use of redis.clients.jedis.ShardedJedis in project blog by liqianggh.
the class RedisShardedPoolUtil method set.
// set方法
public static String set(String key, String value) {
ShardedJedis jedis = null;
String result = null;
try {
jedis = RedisShardedPool.getJedis();
result = jedis.set(key, value);
} catch (Exception e) {
log.error("set key:{} value:{} error", key, value, e);
RedisShardedPool.returnBrokenResource(jedis);
return result;
}
RedisShardedPool.returnResource(jedis);
return result;
}
use of redis.clients.jedis.ShardedJedis in project blog by liqianggh.
the class RedisShardedPoolUtil method sismember.
// sismember 方法
public static Boolean sismember(String key, String member) {
ShardedJedis jedis = null;
Boolean result = false;
try {
jedis = RedisShardedPool.getJedis();
result = jedis.sismember(key, member);
} catch (Exception e) {
log.error("sismember key:{} error", key, e);
RedisShardedPool.returnBrokenResource(jedis);
return result;
}
RedisShardedPool.returnResource(jedis);
return result;
}
use of redis.clients.jedis.ShardedJedis in project blog by liqianggh.
the class RedisShardedPoolUtil method sadd.
// sadd方法
public static Long sadd(String key, String value, Integer expireTime) {
ShardedJedis jedis = null;
Long result = null;
if (expireTime == null) {
expireTime = 60 * 30;
}
try {
jedis = RedisShardedPool.getJedis();
result = jedis.sadd(key, value);
jedis.expire(key, Const.CacheTime.VIEW_COUNT_TIME);
} catch (Exception e) {
log.error("sadd key:{} value:{} error", key, value, e);
RedisShardedPool.returnBrokenResource(jedis);
}
RedisShardedPool.returnResource(jedis);
return result;
}
use of redis.clients.jedis.ShardedJedis in project blog by liqianggh.
the class RedisShardedPoolUtil method hdel.
// hdel
public static Long hdel(String key, String filed) {
ShardedJedis jedis = null;
Long result = null;
try {
jedis = RedisShardedPool.getJedis();
result = jedis.hdel(key, filed);
} catch (Exception e) {
log.error("hget key:{} filed:{} error{}", key, filed, e);
RedisShardedPool.returnBrokenResource(jedis);
}
RedisShardedPool.returnResource(jedis);
return result;
}
Aggregations