当前位置: 首页>>代码示例>>Java>>正文


Java JedisPoolConfig.setMaxWaitMillis方法代码示例

本文整理汇总了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);
}
 
开发者ID:StevenKin,项目名称:ZhihuQuestionsSpider,代码行数:20,代码来源:JedisHolder.java

示例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;
}
 
开发者ID:vy,项目名称:log4j2-redis-appender,代码行数:24,代码来源:RedisConnectionPoolConfig.java

示例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;
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:18,代码来源:ClusterConfig.java

示例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;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:10,代码来源:RedisClusterConfig.java

示例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;
}
 
开发者ID:tomoncle,项目名称:JavaStudy,代码行数:14,代码来源:RedisBeans.java

示例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) {
				}
			});

}
 
开发者ID:MeiPian,项目名称:delay-queue,代码行数:38,代码来源:TestRedisDelayQueue.java

示例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);
}
 
开发者ID:ganpengyu,项目名称:gedis,代码行数:42,代码来源:GedisCacheFactory.java

示例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);
	}
}
 
开发者ID:javay,项目名称:zheng-lite,代码行数:16,代码来源:RedisUtil.java

示例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;
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:10,代码来源:PoolUtil.java

示例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);

}
 
开发者ID:TwoDragonLake,项目名称:tdl-seckill,代码行数:16,代码来源:RedisUtil.java

示例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;
}
 
开发者ID:ZhuXS,项目名称:Spring-Shiro-Spark,代码行数:11,代码来源:RedisCacheConfig.java

示例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;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:11,代码来源:JedisConfig.java

示例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";
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:RedisService.java

示例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;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:15,代码来源:LocalRedisConnectionFactoryConfig.java

示例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());
		}
	}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:29,代码来源:RedisCacheClient.java


注:本文中的redis.clients.jedis.JedisPoolConfig.setMaxWaitMillis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。