當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。