本文整理匯總了Java中redis.clients.jedis.JedisPoolConfig.setLifo方法的典型用法代碼示例。如果您正苦於以下問題:Java JedisPoolConfig.setLifo方法的具體用法?Java JedisPoolConfig.setLifo怎麽用?Java JedisPoolConfig.setLifo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.JedisPoolConfig
的用法示例。
在下文中一共展示了JedisPoolConfig.setLifo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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")));
}
示例3: JedisHolder
import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
private JedisHolder(SpiderConfig config) {
this.config = config;
this.redisIp = this.config.getRedisIp();
this.redisPort = this.config.getRedisPort();
JedisPoolConfig config1 = new JedisPoolConfig();
config1.setLifo(true);
config1.setMaxIdle(8);
config1.setMaxTotal(8);
config1.setMaxWaitMillis(-1);
config1.setMinEvictableIdleTimeMillis(1800000);
config1.setMinIdle(0);
config1.setNumTestsPerEvictionRun(3);
config1.setSoftMinEvictableIdleTimeMillis(1800000);
config1.setTestOnBorrow(false);
config1.setTestWhileIdle(false);
config1.setTimeBetweenEvictionRunsMillis(-1);
this.jedisPool = new JedisPool(config1, this.redisIp, this.redisPort, 3000);
}