本文整理匯總了Java中redis.clients.jedis.JedisPoolConfig.setMinEvictableIdleTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java JedisPoolConfig.setMinEvictableIdleTimeMillis方法的具體用法?Java JedisPoolConfig.setMinEvictableIdleTimeMillis怎麽用?Java JedisPoolConfig.setMinEvictableIdleTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.JedisPoolConfig
的用法示例。
在下文中一共展示了JedisPoolConfig.setMinEvictableIdleTimeMillis方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Client
import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
/**
* Create a new client to a RediSearch index
* @param indexName the name of the index we are connecting to or creating
* @param host the redis host
* @param port the redis pot
*/
public Client(String indexName, String host, int port, int timeout, int poolSize) {
JedisPoolConfig conf = new JedisPoolConfig();
conf.setMaxTotal(poolSize);
conf.setTestOnBorrow(false);
conf.setTestOnReturn(false);
conf.setTestOnCreate(false);
conf.setTestWhileIdle(false);
conf.setMinEvictableIdleTimeMillis(60000);
conf.setTimeBetweenEvictionRunsMillis(30000);
conf.setNumTestsPerEvictionRun(-1);
conf.setFairness(true);
pool = new JedisPool(conf, host, port, timeout);
this.indexName = indexName;
this.commands = new Commands.SingleNodeCommands();
}
示例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;
}
示例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);
}
示例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;
}
示例5: initRedisProvider
import redis.clients.jedis.JedisPoolConfig; //導入方法依賴的package包/類
public static void initRedisProvider() {
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(1);
poolConfig.setMinEvictableIdleTimeMillis(60 * 1000);
poolConfig.setMaxTotal(5);
poolConfig.setMaxWaitMillis(30 * 1000);
String[] servers = "127.0.0.1:6379".split(",");
int timeout = 3000;
String password = null;
int database = 0;
JedisProvider<Jedis, BinaryJedis> provider = new JedisStandaloneProvider("default", poolConfig, servers, timeout, password,
database, null);
JedisProviderFactory.setDefaultJedisProvider(provider);
}
示例6: 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()));
}
}