本文整理汇总了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);
}