本文整理汇总了Java中redis.clients.jedis.JedisPoolConfig.setMaxWaitMillis方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPoolConfig.setMaxWaitMillis方法的具体用法?Java JedisPoolConfig.setMaxWaitMillis怎么用?Java JedisPoolConfig.setMaxWaitMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.JedisPoolConfig
的用法示例。
在下文中一共展示了JedisPoolConfig.setMaxWaitMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例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: getRedisCluster
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisCluster getRedisCluster(){
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes1"), Integer.parseInt(environment.getProperty("redis.cluster.port1"))));
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes2"), Integer.parseInt(environment.getProperty("redis.cluster.port2"))));
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes3"), Integer.parseInt(environment.getProperty("redis.cluster.port3"))));
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes4"), Integer.parseInt(environment.getProperty("redis.cluster.port4"))));
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes5"), Integer.parseInt(environment.getProperty("redis.cluster.port5"))));
jedisClusterNode.add(new HostAndPort(environment.getProperty("redis.cluster.nodes6"), Integer.parseInt(environment.getProperty("redis.cluster.port6"))));
JedisPoolConfig cfg = new JedisPoolConfig();
cfg.setMaxTotal(Integer.parseInt(environment.getProperty("redis.cluster.config.max-total")));
cfg.setMaxIdle(Integer.parseInt(environment.getProperty("redis.cluster.config.max-idle")));
cfg.setMaxWaitMillis(Integer.parseInt(environment.getProperty("redis.cluster.config.max-waitmillis")));
cfg.setTestOnBorrow(Boolean.parseBoolean(environment.getProperty("redis.cluster.config.onborrow")));
JedisCluster jc = new JedisCluster(jedisClusterNode, Integer.parseInt(environment.getProperty("redis.cluster.timeout")), Integer.parseInt(environment.getProperty("redis.cluster.max-redirections")), cfg);
return jc;
}
示例4: getJedisPoolConfig
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisPoolConfig getJedisPoolConfig() {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(redisProperties.getMaxTotal());
jedisPoolConfig.setMaxIdle(redisProperties.getMaxIdle());
jedisPoolConfig.setMinIdle(redisProperties.getMinIdle());
jedisPoolConfig.setMaxWaitMillis(redisProperties.getMaxWaitMillis());
return jedisPoolConfig;
}
示例5: poolConfig
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
* redis 连接池配置
* @return
*/
@Bean
public JedisPoolConfig poolConfig(){
JedisPoolConfig jpc=new JedisPoolConfig();
jpc.setMaxIdle(this.configMaxIdle);
jpc.setTestOnBorrow(this.configTestOnBorrow);
jpc.setMaxWaitMillis(this.configMaxWaitMillis);
jpc.setMaxTotal(this.configMaxTotal);
return jpc;
}
示例6: init
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
String ip = "192.168.2.160";
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort(ip, 7701));
nodes.add(new HostAndPort(ip, 7702));
nodes.add(new HostAndPort(ip, 7703));
nodes.add(new HostAndPort(ip, 7704));
nodes.add(new HostAndPort(ip, 7705));
nodes.add(new HostAndPort(ip, 7706));
JedisPoolConfig pool = new JedisPoolConfig();
pool.setMaxTotal(100);
pool.setFairness(false);
pool.setNumTestsPerEvictionRun(100);
pool.setMaxWaitMillis(5000);
pool.setTestOnBorrow(true);
jedisCluster = new JedisCluster(nodes, 1000, 1000, 100, null, pool); // maxAttempt必须调大
jedisCluster.set("test", "test");
queue = new RedisDelayQueue("com.meipian", "delayqueue", jedisCluster, 60 * 1000,
new DelayQueueProcessListener() {
@Override
public void pushCallback(Message message) {
}
@Override
public void peekCallback(Message message) {
System.out.println("message----->" + message);
queue.ack(message.getId());//确认操作。将会删除消息
}
@Override
public void ackCallback(Message message) {
}
});
}
示例7: GedisCacheFactory
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
* 基于配置构造 GedisCacheFactory
*
* @param configPrefix Redis 配置信息前缀
* @param writeInitParam 写实例初始化配置信息
* @param readInitParams 读实例初始化配置信息
*/
public GedisCacheFactory(String configPrefix, GedisInitParam writeInitParam, List<GedisInitParam> readInitParams) {
if (writeInitParam == null && readInitParams == null && readInitParams.size() > 0) {
throw new IllegalArgumentException("WriteInitParam and ReadInitParams can not both be null.");
}
this.configPrefix = configPrefix;
try {
if (writeInitParam != null) {
JedisPoolConfig writeConfig = new JedisPoolConfig();
writeConfig.setMaxTotal(writeInitParam.getMaxTotal());
writeConfig.setMinIdle(writeInitParam.getMinIdle());
writeConfig.setMaxIdle(writeInitParam.getMaxIdle());
writeConfig.setMaxWaitMillis(writeInitParam.getMaxWaitInMillis());
writeConfig.setTestOnBorrow(writeInitParam.isTestOnBorrow());
writeInstance = new JedisPool(writeConfig, writeInitParam.getIp(), writeInitParam.getPort(), writeInitParam.getConnectTimeoutInMillis(), writeInitParam.getPassword());
}
if (readInitParams != null && readInitParams.size() > 0) {
for (GedisInitParam param : readInitParams) {
JedisPoolConfig readConfig = new JedisPoolConfig();
readConfig.setMaxTotal(param.getMaxTotal());
readConfig.setMinIdle(param.getMinIdle());
readConfig.setMaxIdle(param.getMaxIdle());
readConfig.setMaxWaitMillis(param.getMaxWaitInMillis());
readConfig.setTestOnBorrow(param.isTestOnBorrow());
JedisPool readInstance = new JedisPool(readConfig, param.getIp(), param.getPort(), param.getConnectTimeoutInMillis(), param.getPassword());
this.readInstances.add(readInstance);
}
}
} catch (Exception e) {
log.error("GedisCacheFactory init failed, please check init params, error {}", e);
throw e;
}
jedisInterface = new IJedisImpl(writeInstance, readInstances);
methodInterceptor = new JedisMethodInterceptor(writeInstance, readInstances);
}
示例8: initialPool
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
* 初始化Redis连接池
*/
private static void initialPool() {
try {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(MAX_ACTIVE);
config.setMaxIdle(MAX_IDLE);
config.setMaxWaitMillis(MAX_WAIT);
config.setTestOnBorrow(TEST_ON_BORROW);
jedisPool = new JedisPool(config, IP, PORT, TIMEOUT);
} catch (Exception e) {
_log.error("First create JedisPool error : " + e);
}
}
示例9: defaultPoolConfig
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static JedisPoolConfig defaultPoolConfig() {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(maxCount);
config.setMaxIdle(maxIdle);
config.setMaxWaitMillis(MaxWait);
config.setTestOnBorrow(false);
config.setTestOnReturn(false);
return config;
}
示例10: afterPropertiesSet
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
* 初始化redisUtil实例,配置连接池
*/
public void afterPropertiesSet() throws Exception {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(maxTotal);
config.setMaxIdle(maxIdle);
config.setMinIdle(minIdle);
config.setMaxWaitMillis(holed);
config.setTestOnBorrow(false);
pool = new JedisPool(config, host, port, timeout, password, DB);
}
示例11: redisPoolFactory
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisPool redisPoolFactory() {
logger.info("redis: " + host + ":" + port);
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(maxIdle);
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);
return jedisPool;
}
示例12: jedisPoolConfig
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisPoolConfig jedisPoolConfig() {
JedisPoolConfig config = new JedisPoolConfig();
config.setMinIdle(PropertiesUtil.getInt("redis.minIdle"));
config.setMaxIdle(PropertiesUtil.getInt("redis.maxIdle"));
config.setMaxTotal(PropertiesUtil.getInt("redis.maxTotal"));
config.setMaxWaitMillis(PropertiesUtil.getInt("redis.maxWaitMillis"));
config.setTestOnBorrow(Boolean.valueOf(PropertiesUtil.getString("redis.testOnBorrow")));
return config;
}
示例13: jedispolltest
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@GET
@Path("jedispooltest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedispolltest() {
System.out.println("TEST JedisPool ======================================================");
JedisPoolConfig cfg = new JedisPoolConfig();
cfg.setMaxTotal(5);
cfg.setMaxIdle(1);
cfg.setMaxWaitMillis(10000L);
JedisPool jp = new JedisPool(cfg, "localhost", 6379);
Jedis jedis = jp.getResource();
jedis.set("foo", "bar");
// jedis.close();
jedis = jp.getResource();
jedis.get("foo");
// jedis.close();
jedis = jp.getResource();
jedis.lpush("lll", "a");
jedis.lpush("lll", "b");
jedis.lpush("lll", "c");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.lpop("lll");
// jedis.close();
jedis = jp.getResource();
jedis.hset("mmm", "abc", "123");
jedis.hset("mmm", "def", "456");
jedis.hgetAll("mmm");
jp.close();
return "jedispooltest";
}
示例14: createJedisConnectionFactory
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private RedisConnectionFactory createJedisConnectionFactory(final LocalRedisProperties redisProperties) {
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(redisProperties.getMinActive());
poolConfig.setMinIdle(redisProperties.getMaxActive());
poolConfig.setMaxWaitMillis(redisProperties.getMaxWaitTime());
poolConfig.setTestOnBorrow(false);
JedisConnectionFactory connFactory = new JedisConnectionFactory(poolConfig);
connFactory.setUsePool(false);
connFactory.setTimeout(redisProperties.getSoTimeout());
connFactory.setHostName(redisProperties.getRedisHost());
connFactory.setPort(redisProperties.getRedisPort());
return connFactory;
}
示例15: init
import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public void init() {
try {
String[] hosts = servers.trim().split("\\|");
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
for (String host : hosts) {
String[] ss = host.split(":");
//升级 redis 构造变化
JedisShardInfo shard = new JedisShardInfo(ss[0], Integer.parseInt(ss[1]), DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, 1);
shards.add(shard);
}
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxIdle(MAX_ACTIVE);
config.setMinIdle(MAX_IDLE);
config.setMaxWaitMillis(MAX_WAIT);
config.setMaxTotal(MAX_TOTAL);
pool = new ShardedJedisPool(config, shards, Hashing.MURMUR_HASH);
} catch (NumberFormatException e) {
System.out.println("redis客户端初始化连接异常!!!!!!!!! 链接参数:" + servers
+ " " + DEFAULT_TIMEOUT + " " + app);
logger.error("redis:{},exception:{}.", servers + " "
+ DEFAULT_TIMEOUT + " " + app, e.getMessage());
}
}