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


Java JedisPoolConfig.setBlockWhenExhausted方法代碼示例

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


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

示例1: jedisConnConfig

import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
private void jedisConnConfig(final JedisConnectionFactory jedisConnectionFactory) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    try {
        poolConfig.setMaxTotal(Integer.parseInt(REDIS_MAXTOTAL.getValue()));
        poolConfig.setMaxIdle(Integer.parseInt(REDIS_MAXIDLE.getValue()));
        poolConfig.setBlockWhenExhausted(true);
        if (!"".equals(REDIS_PASSWORD.getValue())) {
            jedisConnectionFactory.setPassword(REDIS_PASSWORD.getValue());
        }
        if (!"".equals(REDIS_DATABASE.getValue())) {
            jedisConnectionFactory.setDatabase(Integer.parseInt(REDIS_DATABASE.getValue()));
        }
        jedisConnectionFactory.setPoolConfig(poolConfig);
        jedisConnectionFactory.setUsePool(true);
        jedisConnectionFactory.setTimeout(Integer.parseInt(REDIS_TIMEOUT.getValue()));
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
開發者ID:globocom,項目名稱:groot,代碼行數:20,代碼來源:RedisConfiguration.java

示例2: createJedisPoolConfig

import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
private static JedisPoolConfig createJedisPoolConfig(Builder builder) {
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(builder.maxTotal);
    config.setMaxIdle(builder.maxIdle);
    config.setMinIdle(builder.minIdle);
    config.setLifo(builder.lifo);
    config.setFairness(builder.fairness);
    config.setMaxWaitMillis(builder.maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(builder.minEvictableIdleTimeMillis);
    config.setSoftMinEvictableIdleTimeMillis(builder.softMinEvictableIdleTimeMillis);
    config.setNumTestsPerEvictionRun(builder.numTestsPerEvictionRun);
    config.setTestOnCreate(builder.testOnCreate);
    config.setTestOnBorrow(builder.testOnBorrow);
    config.setTestOnReturn(builder.testOnReturn);
    config.setTestWhileIdle(builder.testWhileIdle);
    config.setTimeBetweenEvictionRunsMillis(builder.timeBetweenEvictionRunsMillis);
    config.setEvictionPolicyClassName(builder.evictionPolicyClassName);
    config.setBlockWhenExhausted(builder.blockWhenExhausted);
    config.setJmxEnabled(builder.jmxEnabled);
    config.setJmxNameBase(builder.jmxNameBase);
    config.setJmxNamePrefix(builder.jmxNamePrefix);
    return config;
}
 
開發者ID:vy,項目名稱:log4j2-redis-appender,代碼行數:24,代碼來源:RedisConnectionPoolConfig.java

示例3: JedisPoolConfigFactory

import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
private JedisPoolConfigFactory() {
	config = new JedisPoolConfig();
	//連接耗盡時是否阻塞, false報異常,ture阻塞直到超時, 默認true
   	config.setBlockWhenExhausted(true);
   	//設置的逐出策略類名, 默認DefaultEvictionPolicy(當連接超過最大空閑時間,或連接數超過最大空閑連接數)
   	config.setEvictionPolicyClassName("org.apache.commons.pool2.impl.DefaultEvictionPolicy");
   	//是否啟用pool的jmx管理功能, 默認true
   	config.setJmxEnabled(true);
   	//是否啟用後進先出, 默認true
   	config.setLifo(true);
   	//最大空閑連接數, 默認8個
   	config.setMaxIdle(Integer.parseInt(Config.getAttribute("maxIdle")));
   	//最大連接數, 默認8個
   	config.setMaxTotal(Integer.parseInt(Config.getAttribute("maxTotal")));
   	//獲取連接時的最大等待毫秒數(如果設置為阻塞時BlockWhenExhausted),如果超時就拋異常, 小於零:阻塞不確定的時間,  默認-1
   	config.setMaxWaitMillis(Integer.parseInt(Config.getAttribute("maxWait")));
   	//最小空閑連接數, 默認0
   	config.setMinIdle(Integer.parseInt(Config.getAttribute("minIdle")));
   	//在獲取連接的時候檢查有效性, 默認false
   	config.setTestOnBorrow(Boolean.parseBoolean(Config.getAttribute("testOnBorrow")));
   	//在空閑時檢查有效性, 默認false
   	config.setTestWhileIdle(Boolean.parseBoolean(Config.getAttribute("testOnReturn")));
}
 
開發者ID:rocye,項目名稱:wx-idk,代碼行數:24,代碼來源:JedisPoolConfigFactory.java

示例4: buildPoolConfig

import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
private static JedisPoolConfig buildPoolConfig() {
	final JedisPoolConfig poolConfig = new JedisPoolConfig();
	poolConfig.setMaxTotal(128);
	poolConfig.setMaxIdle(128);
	poolConfig.setMinIdle(16);
	poolConfig.setTestOnBorrow(true);
	poolConfig.setTestOnReturn(true);
	poolConfig.setTestWhileIdle(true);
	poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis());
	poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis());
	poolConfig.setNumTestsPerEvictionRun(3);
	poolConfig.setBlockWhenExhausted(true);

	return poolConfig;
}
 
開發者ID:SystemOfAProg,項目名稱:VS2Labor,代碼行數:16,代碼來源:JedisFactory.java

示例5: setPoolParameters

import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
/**
 * 處理連接池信息
 * 
 * @param poolConfig 參數說明
 * @param config 參數說明
 */
private void setPoolParameters(PoolConfig poolConfig, JedisPoolConfig config) {
	
    if (!StringUtils.isBlank(poolConfig.getMaxIdle())) {
    	// 獲取最大空閑連接數
        config.setMaxIdle(Integer.valueOf(poolConfig.getMaxIdle()));
    }    
    
    if (!StringUtils.isBlank(poolConfig.getMinIdle())) {
    	// 獲取最小空閑連接數
        config.setMinIdle(Integer.valueOf(poolConfig.getMinIdle()));
    }           
    
    if (!StringUtils.isBlank(poolConfig.getMaxTotal())) {
    	// 獲取最大連接數
        config.setMaxTotal(Integer.valueOf(poolConfig.getMaxTotal()));
    }  
    
    if (!StringUtils.isBlank(poolConfig.getTestOnBorrow())) {
        // 獲取連接池是否檢測可用性
        config.setTestOnBorrow(Boolean.valueOf(poolConfig.getTestOnBorrow()));
    }

    if (!StringUtils.isBlank(poolConfig.getTestOnReturn())) {
        // 歸還時是否檢測可用性
        config.setTestOnReturn(Boolean.valueOf(poolConfig.getTestOnReturn()));
    }
    if (!StringUtils.isBlank(poolConfig.getTestWhileIdle())) {
        // 空閑時是否檢測可用性
        config.setTestWhileIdle(Boolean.valueOf(poolConfig.getTestWhileIdle()));
    } else {
    	config.setTestWhileIdle(true);
    }
    if (!StringUtils.isBlank(poolConfig.getBlockWhenExhausted())) {
        config.setBlockWhenExhausted(Boolean.valueOf(poolConfig.getBlockWhenExhausted()));
    }
    if (!StringUtils.isBlank(poolConfig.getTimeBetweenEvictionRunsMillis())) {
        config.setTimeBetweenEvictionRunsMillis(Long.valueOf(poolConfig.getTimeBetweenEvictionRunsMillis()));
    } else {
    	config.setTimeBetweenEvictionRunsMillis(30000L);
    }
    if (!StringUtils.isBlank(poolConfig.getNumTestsPerEvictionRun())) {
        config.setNumTestsPerEvictionRun(Integer.valueOf(poolConfig.getNumTestsPerEvictionRun()));
    } else {
    	config.setNumTestsPerEvictionRun(-1);
    }
    if (!StringUtils.isBlank(poolConfig.getMinEvictableIdleTimeMillis())) {
        config.setMinEvictableIdleTimeMillis(Integer.valueOf(poolConfig.getMinEvictableIdleTimeMillis()));
    } else {
        config.setMinEvictableIdleTimeMillis(60000L);
    }
    if (!StringUtils.isBlank(poolConfig.getSoftMinEvictableIdleTimeMillis())) {
        config.setSoftMinEvictableIdleTimeMillis(Integer.valueOf(poolConfig.getSoftMinEvictableIdleTimeMillis()));
    }
}
 
開發者ID:ningyu1,項目名稱:jodis-client,代碼行數:61,代碼來源:DefaultClientImpl.java


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