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


Java JedisPoolConfig.setTestOnReturn方法代码示例

本文整理汇总了Java中redis.clients.jedis.JedisPoolConfig.setTestOnReturn方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPoolConfig.setTestOnReturn方法的具体用法?Java JedisPoolConfig.setTestOnReturn怎么用?Java JedisPoolConfig.setTestOnReturn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.JedisPoolConfig的用法示例。


在下文中一共展示了JedisPoolConfig.setTestOnReturn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
 
开发者ID:RedisLabs,项目名称:JRediSearch,代码行数:24,代码来源:Client.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: connectionFactory

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisConnectionFactory connectionFactory() {
  JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
  jedisPoolConfig.setMaxTotal(Integer.parseInt(env.getProperty(REDIS_POOL_MAX_ACTIVE)));
  jedisPoolConfig.setMaxIdle(Integer.parseInt(env.getProperty(REDIS_POOL_MAX_IDLE)));
  jedisPoolConfig.setMinIdle(Integer.parseInt(env.getProperty(REDIS_POOL_MIN_IDLE)));
  jedisPoolConfig.setMaxWaitMillis(Long.parseLong(env.getProperty(REDIS_POOL_MAX_WAIT)));
  jedisPoolConfig.setTestOnBorrow(true);
  jedisPoolConfig.setTestOnReturn(true);
  jedisPoolConfig.setTestWhileIdle(true);

  JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(jedisPoolConfig);
  jedisConnectionFactory.setUsePool(true);
  jedisConnectionFactory.setHostName(env.getProperty((REDIS_REMOTE_HOST)));
  return jedisConnectionFactory;
}
 
开发者ID:chuangxian,项目名称:lib-edge,代码行数:17,代码来源:RedisSessionConfiguration.java

示例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;
}
 
开发者ID:SystemOfAProg,项目名称:VS2Labor,代码行数:16,代码来源:JedisFactory.java

示例5: 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

示例6: main

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
public static void main(String[] args) {
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(50000);
    jedisPoolConfig.setMaxIdle(20000);
    jedisPoolConfig.setMaxWaitMillis(3000);
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPoolConfig.setTestOnReturn(true);

    List<JedisShardInfo> shards = new ArrayList<>();
    shards.add(new JedisShardInfo("127.0.0.1", 6379, 300));
    ShardedJedisPool shardedJedisPool = new ShardedJedisPool(jedisPoolConfig, shards);
    RedisService redisService = new RedisService(shardedJedisPool);
    new Thread(new HallTcpService(redisService)).start();
    new Thread(new HallNoticeService(redisService)).start();
}
 
开发者ID:peng9627,项目名称:hall,代码行数:16,代码来源:StartGame.java

示例7: getPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
 * method to get jedis pool configuration
 * 
 * @param properties
 * @return
 */
private JedisPoolConfig getPoolConfig(Properties properties) {
	JedisPoolConfig poolConfig = new JedisPoolConfig();
	int maxActive = Integer.parseInt(properties.getProperty(RedisConstants.MAX_ACTIVE, RedisConstants.DEFAULT_MAX_ACTIVE_VALUE));
	poolConfig.setMaxTotal(maxActive);

	boolean testOnBorrow = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_ONBORROW, RedisConstants.DEFAULT_TEST_ONBORROW_VALUE));
	poolConfig.setTestOnBorrow(testOnBorrow);

	boolean testOnReturn = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_ONRETURN, RedisConstants.DEFAULT_TEST_ONRETURN_VALUE));
	poolConfig.setTestOnReturn(testOnReturn);

	int maxIdle = Integer.parseInt(properties.getProperty(RedisConstants.MAX_ACTIVE, RedisConstants.DEFAULT_MAX_ACTIVE_VALUE));
	poolConfig.setMaxIdle(maxIdle);

	int minIdle = Integer.parseInt(properties.getProperty(RedisConstants.MIN_IDLE, RedisConstants.DEFAULT_MIN_IDLE_VALUE));
	poolConfig.setMinIdle(minIdle);

	boolean testWhileIdle = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_WHILEIDLE, RedisConstants.DEFAULT_TEST_WHILEIDLE_VALUE));
	poolConfig.setTestWhileIdle(testWhileIdle);

	int testNumPerEviction = Integer.parseInt(properties.getProperty(RedisConstants.TEST_NUMPEREVICTION, RedisConstants.DEFAULT_TEST_NUMPEREVICTION_VALUE));
	poolConfig.setNumTestsPerEvictionRun(testNumPerEviction);

	long timeBetweenEviction = Long.parseLong(properties.getProperty(RedisConstants.TIME_BETWEENEVICTION, RedisConstants.DEFAULT_TIME_BETWEENEVICTION_VALUE));
	poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEviction);
	return poolConfig;
}
 
开发者ID:ran-jit,项目名称:distributed-task-scheduler,代码行数:34,代码来源:RedisDataCache.java

示例8: redisConnectionFactory

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
@Bean
public JedisConnectionFactory redisConnectionFactory() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(5);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setTestOnReturn(true);
    JedisConnectionFactory ob = new JedisConnectionFactory(poolConfig);
    ob.setUsePool(true);
    String redishost = cacheProperties.getRedisHost(); //System.getenv("REDISCACHE_HOSTNAME");
    LOG.info("REDISCACHE_HOSTNAME={}", redishost);
    ob.setHostName(redishost);
    String redisport = cacheProperties.getRedisPort().toString(); //System.getenv("REDISCACHE_PORT");
    LOG.info("REDISCACHE_PORT= {}", redisport);
    try {
        ob.setPort(Integer.parseInt(  redisport));
    } catch (NumberFormatException e1) {
        // if the port is not in the ENV, use the default
        ob.setPort(6379);
    }
    String rediskey = cacheProperties.getPrimaryKey(); //System.getenv("REDISCACHE_PRIMARY_KEY");
    LOG.info("REDISCACHE_PRIMARY_KEY= {}", rediskey);
    ob.setPassword(rediskey);
    ob.afterPropertiesSet();
    RedisTemplate<Object,Object> tmp = new RedisTemplate<>();
    tmp.setConnectionFactory(ob);

    //make sure redis connection is working
    try {
        String msg = tmp.getConnectionFactory().getConnection().ping();
        LOG.info("redis ping response="+msg);
        //clear the cache before use
        tmp.getConnectionFactory().getConnection().flushAll();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return ob;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:39,代码来源:CacheConfig.java

示例9: 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()));
    }
}
 
开发者ID:ningyu1,项目名称:jodis-client,代码行数:61,代码来源:DefaultClientImpl.java


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