本文整理了Java中redis.clients.jedis.Jedis.close()
方法的一些代码示例,展示了Jedis.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.close()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:close
暂无
代码示例来源:origin: apache/storm
/**
* Returns Jedis instance to pool.
*
* @param jedis Jedis instance to return to pool
*/
public void returnJedis(Jedis jedis) {
jedis.close();
}
代码示例来源:origin: apache/storm
@Override
public void close() throws IOException {
jedis.close();
}
}
代码示例来源:origin: sohutv/cachecloud
private void releaseConnection(Jedis connection) {
if (connection != null) {
connection.close();
}
}
代码示例来源:origin: qiurunze123/miaosha
private void returnToPool(Jedis jedis) {
if(jedis != null) {
jedis.close();
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 删除值
* @param key
*/
public synchronized static void remove(String key) {
try {
Jedis jedis = getJedis();
jedis.del(key);
jedis.close();
} catch (Exception e) {
LOGGER.error("Remove keyex error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 删除值
* @param key
*/
public synchronized static void remove(byte[] key) {
try {
Jedis jedis = getJedis();
jedis.del(key);
jedis.close();
} catch (Exception e) {
LOGGER.error("Remove keyex error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 获取byte[]值
* @param key
* @return value
*/
public synchronized static byte[] get(byte[] key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
byte[] value = jedis.get(key);
jedis.close();
return value;
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 byte[]
* @param key
* @param value
*/
public synchronized static void set(byte[] key, byte[] value) {
try {
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 获取String值
* @param key
* @return value
*/
public synchronized static String get(String key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
String value = jedis.get(key);
jedis.close();
return value;
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 String
* @param key
* @param value
*/
public synchronized static void set(String key, String value) {
try {
value = StringUtils.isBlank(value) ? "" : value;
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 byte[] 过期时间
* @param key
* @param value
* @param seconds 以秒为单位
*/
public synchronized static void set(byte[] key, byte[] value, int seconds) {
try {
Jedis jedis = getJedis();
jedis.set(key, value);
jedis.expire(key, seconds);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set key error : " + e);
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void onMessage(String key, String msg) {
if (logger.isInfoEnabled()) {
logger.info("redis event: " + key + " = " + msg);
}
if (msg.equals(Constants.REGISTER)
|| msg.equals(Constants.UNREGISTER)) {
try {
Jedis jedis = jedisPool.getResource();
try {
doNotify(jedis, key);
} finally {
jedis.close();
}
} catch (Throwable t) { // TODO Notification failure does not restore mechanism guarantee
logger.error(t.getMessage(), t);
}
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void onMessage(String key, String msg) {
if (logger.isInfoEnabled()) {
logger.info("redis event: " + key + " = " + msg);
}
if (msg.equals(Constants.REGISTER)
|| msg.equals(Constants.UNREGISTER)) {
try {
Jedis jedis = jedisPool.getResource();
try {
doNotify(jedis, key);
} finally {
jedis.close();
}
} catch (Throwable t) { // TODO Notification failure does not restore mechanism guarantee
logger.error(t.getMessage(), t);
}
}
}
代码示例来源:origin: shuzheng/zheng
/**
* 设置 String 过期时间
* @param key
* @param value
* @param seconds 以秒为单位
*/
public synchronized static void set(String key, String value, int seconds) {
try {
value = StringUtils.isBlank(value) ? "" : value;
Jedis jedis = getJedis();
jedis.setex(key, seconds, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("Set keyex error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* lpush
* @param key
* @param key
*/
public synchronized static void lpush(String key, String... strings) {
try {
Jedis jedis = RedisUtil.getJedis();
jedis.lpush(key, strings);
jedis.close();
} catch (Exception e) {
LOGGER.error("lpush error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* lrem
* @param key
* @param count
* @param value
*/
public synchronized static void lrem(String key, long count, String value) {
try {
Jedis jedis = RedisUtil.getJedis();
jedis.lrem(key, count, value);
jedis.close();
} catch (Exception e) {
LOGGER.error("lpush error : " + e);
}
}
代码示例来源:origin: shuzheng/zheng
/**
* decr
* @param key
* @return value
*/
public synchronized static Long decr(String key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
long value = jedis.decr(key);
jedis.close();
return value;
}
代码示例来源:origin: shuzheng/zheng
/**
* incr
* @param key
* @return value
*/
public synchronized static Long incr(String key) {
Jedis jedis = getJedis();
if (null == jedis) {
return null;
}
long value = jedis.incr(key);
jedis.close();
return value;
}
代码示例来源:origin: shuzheng/zheng
/**
* sadd
* @param key
* @param value
* @param seconds
*/
public synchronized static void sadd(String key, String value, int seconds) {
try {
Jedis jedis = RedisUtil.getJedis();
jedis.sadd(key, value);
jedis.expire(key, seconds);
jedis.close();
} catch (Exception e) {
LOGGER.error("sadd error : " + e);
}
}
代码示例来源:origin: code4craft/webmagic
@Override
protected void pushWhenNoDuplicate(Request request, Task task) {
Jedis jedis = pool.getResource();
try {
jedis.rpush(getQueueKey(task), request.getUrl());
if (checkForAdditionalInfo(request)) {
String field = DigestUtils.shaHex(request.getUrl());
String value = JSON.toJSONString(request);
jedis.hset((ITEM_PREFIX + task.getUUID()), field, value);
}
} finally {
jedis.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!