本文整理汇总了Java中redis.clients.jedis.JedisPoolConfig.setTestOnCreate方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPoolConfig.setTestOnCreate方法的具体用法?Java JedisPoolConfig.setTestOnCreate怎么用?Java JedisPoolConfig.setTestOnCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.JedisPoolConfig
的用法示例。
在下文中一共展示了JedisPoolConfig.setTestOnCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getRedisConnectionFactory
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private RedisConnectionFactory getRedisConnectionFactory(int database, String host, String password, int port, int maxIdle, int minIdle, int maxWait) {
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setDatabase(database);
connectionFactory.setHostName(host);
connectionFactory.setPassword(password);
connectionFactory.setPort(port);
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(maxIdle);
poolConfig.setMinIdle(minIdle);
poolConfig.setMaxWaitMillis(maxWait);
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnCreate(true);
poolConfig.setTestWhileIdle(true);
connectionFactory.setUsePool(true);
return connectionFactory;
}