當前位置: 首頁>>代碼示例>>Java>>正文


Java Jedis.close方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Jedis.close方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.close方法的具體用法?Java Jedis.close怎麽用?Java Jedis.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Jedis的用法示例。


在下文中一共展示了Jedis.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sentinelMonitor

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Test
public void sentinelMonitor() {
  Jedis j = new Jedis(sentinel.getHost(), sentinel.getPort());

  try {
    // monitor new master
    String result = j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
    assertEquals("OK", result);

    // already monitored
    try {
      j.sentinelMonitor(MONITOR_MASTER_NAME, MASTER_IP, master.getPort(), 1);
      fail();
    } catch (JedisDataException e) {
      // pass
    }
  } finally {
    j.close();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:21,代碼來源:JedisSentinelTest.java

示例2: get

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public String get(String key) {
    Jedis jedis = null;
    String result = "";
    try {
        jedis = getJedis();
        if (jedis != null) {
            result = jedis.get(key);
        } else {
            logger.error("get opt connection null error!");
        }
    } catch (JedisConnectionException e) {
        if (jedis != null) {
            jedis.close();
            jedis = null;
        }
        logger.error("get value connect error:", e);
    } finally {
        returnJedisResource(jedis);
    }
    return result;
}
 
開發者ID:Zephery,項目名稱:newblog,代碼行數:22,代碼來源:JedisUtil.java

示例3: exists

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 判斷是否存在
 * @param existskey
 * @return
 */
public boolean exists(String existskey) throws Exception {
	Jedis jds = null;
	try {
		jds = getJedis();
		jds.select(0);
		return jds.exists(existskey.getBytes());
	} catch (Exception e) {
		throw e;
	} finally {
		if(jds != null)
		{
			jds.close();
		}
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:21,代碼來源:RedisManager.java

示例4: getAllService

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取所有服務列表
 */
public List<String> getAllService(){
	
	Jedis jedis = JedisTemplate.getJedis();
	List<String> services = null;
	try{
		services = jedis.lrange(onlineServices, 0, -1);
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		jedis.close();
	}
	
	return services;
	
}
 
開發者ID:smxc,項目名稱:garlicts,代碼行數:19,代碼來源:SimpleServiceUrlRoute.java

示例5: test_jedis_proxy

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Test
public void test_jedis_proxy() {
    JedisPoolConfig config = new JedisPoolConfig();
    JaRedisPool pool = new JaRedisPool(config, "127.0.0.1", 6379);
    Jedis jedis = pool.getResource();
    jedis.set("hello", "world");
    Assert.assertEquals(jedis.get("hello"), "world");
    jedis.close();
}
 
開發者ID:YanXs,項目名稱:nighthawk,代碼行數:10,代碼來源:TestJedisProxyPool.java

示例6: flushConfig

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 清空配置.
 * @param name 應用opkind
 * @throws Exception Exception
 */
public void flushConfig(final String name) throws Exception{
    Jedis configJedis = o2iJedisPool.getResource();
    Set<String> configSet = configJedis.keys(name+"*");
    if(!CollectionUtils.isEmpty(configSet)){
        configJedis.del(configSet.toArray(new String[0]));
    }
    configJedis.close();
}
 
開發者ID:Zigin,項目名稱:MonitorPlatform,代碼行數:14,代碼來源:O2iMonitorService.java

示例7: set

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public String set(String key, String value) {
	Jedis jedis = jedisPool.getResource();
	String result = jedis.set(key, value);
	jedis.close();
	return result;
}
 
開發者ID:mmdsyl,項目名稱:BLOG-Microservice,代碼行數:8,代碼來源:JedisClientPool.java

示例8: hexists

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public Boolean hexists(String key, String field) {
	Jedis jedis = jedisPool.getResource();
	Boolean result = jedis.hexists(key, field);
	jedis.close();
	return result;
}
 
開發者ID:Exrick,項目名稱:xmall,代碼行數:8,代碼來源:JedisClientPool.java

示例9: get

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 獲取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;
}
 
開發者ID:javay,項目名稱:zheng-lite,代碼行數:15,代碼來源:RedisUtil.java

示例10: sadd

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 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) {
		_log.error("sadd error : " + e);
	}
}
 
開發者ID:javay,項目名稱:zheng-lite,代碼行數:17,代碼來源:RedisUtil.java

示例11: remove

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * 刪除值
 * @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);
	}
}
 
開發者ID:ChangyiHuang,項目名稱:shuzheng,代碼行數:14,代碼來源:RedisUtil.java

示例12: returnResourceShouldResetState

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
      "foobared", 2);

  Jedis jedis = pool.getResource();
  Jedis jedis2 = null;

  try {
    jedis.set("hello", "jedis");
    Transaction t = jedis.multi();
    t.set("hello", "world");
    pool.returnResource(jedis);

    jedis2 = pool.getResource();

    assertTrue(jedis == jedis2);
    assertEquals("jedis", jedis2.get("hello"));
  } catch (JedisConnectionException e) {
    if (jedis2 != null) {
      pool.returnBrokenResource(jedis2);
      jedis2 = null;
    }
  } finally {
    if (jedis2 != null) jedis2.close();

    pool.destroy();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:33,代碼來源:JedisSentinelPoolTest.java

示例13: eval

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
 * Eval lua script command
 *
 * @param script
 * @param keys
 * @param args
 * @return
 */
public Object eval(String script, List<String> keys, List<String> args) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        return jedis.eval(script, keys, args);

    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
}
 
開發者ID:baidu,項目名稱:dlock,代碼行數:21,代碼來源:JedisClient.java

示例14: getStringStringMap

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
private Map<String, String> getStringStringMap(String index) {
    Jedis jedis = getJedis();

    MapStructure<String> mapStructure = RedisStrutureBuilder.ofMap(jedis, String.class).withNameSpace(nameSpace).build();
    Map<String, String> map = mapStructure.get(index);

    Map<String, String> result = new HashMap<>();
    result.putAll(map);
    if (jedis != null) {
        jedis.close();
    }

    return result;
}
 
開發者ID:zerosoft,項目名稱:CodeBroker,代碼行數:15,代碼來源:CacheManager.java

示例15: get

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
public static Object get(String key) {
    Object reval = null;
    Jedis jedis = null;
    try {
        jedis = pool.getResource();
        reval = jedis.get(key);
    } catch (Exception e) {
        LOG.info("Error, idle : " + pool.getNumIdle() + ", active : " + pool.getNumActive() + ", waiter : " + pool.getNumWaiters());
    } finally {
        if(jedis != null) jedis.close();
    }
    return reval;
}
 
開發者ID:JiuzhouSec,項目名稱:nightwatch,代碼行數:14,代碼來源:RedisLookUp.java


注:本文中的redis.clients.jedis.Jedis.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。