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


Java ShardedJedisPool.returnBrokenResource方法代碼示例

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


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

示例1: checkPoolRepairedWhenJedisIsBroken

import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
  ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
  ShardedJedis jedis = pool.getResource();
  jedis.disconnect();
  pool.returnBrokenResource(jedis);

  jedis = pool.getResource();
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:13,代碼來源:ShardedJedisPoolTest.java

示例2: freeRedisResource

import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
public static void freeRedisResource(ShardedJedisPool jedisPool, ShardedJedis shardedJedis, boolean isCommited){
	if (shardedJedis != null && jedisPool != null) {			
		if (isCommited) {				
			jedisPool.returnResource(shardedJedis);
		} else {
			jedisPool.returnBrokenResource(shardedJedis);
		}
	}
}
 
開發者ID:duchien85,項目名稱:netty-cookbook,代碼行數:10,代碼來源:RedisCommand.java

示例3: coverShardJedisException

import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
/**
 * 運行時異常,IO異常,銷毀jedis對象
 *
 * @param ex
 * @param shardedJedisPool
 * @param shardedJedis
 */
protected void coverShardJedisException(Exception ex, ShardedJedisPool shardedJedisPool, ShardedJedis shardedJedis) {
    if (shardedJedis == null) throw new NullPointerException();
    if (ex instanceof JRedisCacheException || ex instanceof IOException) {
        shardedJedisPool.returnBrokenResource(shardedJedis); //銷毀該對象
    }
}
 
開發者ID:chenleijava,項目名稱:springJredisCache,代碼行數:14,代碼來源:JRedisCache.java

示例4: main

import redis.clients.jedis.ShardedJedisPool; //導入方法依賴的package包/類
public static void main(String [] args)
{
    // ���õ�������
    @SuppressWarnings("resource")
    Jedis v_Jedis = new Jedis("127.0.0.1");
    v_Jedis.set("test" ,new Date().getFull());
    System.out.println(v_Jedis.get("test"));
    
    
    
    
    
    // ���ü�Ⱥ����
    // ����ֻ������һ̨������������Ϊ�ӻ����õ�ֻ��ģʽ slave-read-only yes
    JedisShardInfo v_JedisPool_01 = new JedisShardInfo("127.0.0.1" , 6379);
    List<JedisShardInfo> v_JedisPoolList = new ArrayList<JedisShardInfo>();
    
    v_JedisPoolList.add(v_JedisPool_01);
    
    JedisPoolConfig v_JedisPoolConfig = new JedisPoolConfig();
    v_JedisPoolConfig.setMaxTotal(1024);
    v_JedisPoolConfig.setMaxIdle(10);
    v_JedisPoolConfig.setMinIdle(1);
    
    ShardedJedisPool v_ShardedJedisPool = new ShardedJedisPool(v_JedisPoolConfig ,v_JedisPoolList);
    
    
    ShardedJedis v_ShardedJedis = v_ShardedJedisPool.getResource();
    
    v_ShardedJedis.set("test" ,"bar");
    System.out.println(v_ShardedJedis.get("test"));
    
    
    // ���������ӳء����������ʹ�ô˷���
    v_ShardedJedisPool.returnResource(v_ShardedJedis);
    
    // �ͷ�Redis����
    // �ڳ������ʱ���������returnBrokenResource������pool��
    // �����´�ͨ��getResource�õ���instance�Ļ��������ܻ��������ݣ���������
    v_ShardedJedisPool.returnBrokenResource(v_ShardedJedis);
    
    v_ShardedJedisPool.destroy();
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.Redis,代碼行數:44,代碼來源:RedisDemo.java


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