當前位置: 首頁>>代碼示例>>Java>>正文


Java JedisConnectionFactory.setUsePool方法代碼示例

本文整理匯總了Java中org.springframework.data.redis.connection.jedis.JedisConnectionFactory.setUsePool方法的典型用法代碼示例。如果您正苦於以下問題:Java JedisConnectionFactory.setUsePool方法的具體用法?Java JedisConnectionFactory.setUsePool怎麽用?Java JedisConnectionFactory.setUsePool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.data.redis.connection.jedis.JedisConnectionFactory的用法示例。


在下文中一共展示了JedisConnectionFactory.setUsePool方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jedisConnConfig

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
private void jedisConnConfig(final JedisConnectionFactory jedisConnectionFactory) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    try {
        poolConfig.setMaxTotal(Integer.parseInt(REDIS_MAXTOTAL.getValue()));
        poolConfig.setMaxIdle(Integer.parseInt(REDIS_MAXIDLE.getValue()));
        poolConfig.setBlockWhenExhausted(true);
        if (!"".equals(REDIS_PASSWORD.getValue())) {
            jedisConnectionFactory.setPassword(REDIS_PASSWORD.getValue());
        }
        if (!"".equals(REDIS_DATABASE.getValue())) {
            jedisConnectionFactory.setDatabase(Integer.parseInt(REDIS_DATABASE.getValue()));
        }
        jedisConnectionFactory.setPoolConfig(poolConfig);
        jedisConnectionFactory.setUsePool(true);
        jedisConnectionFactory.setTimeout(Integer.parseInt(REDIS_TIMEOUT.getValue()));
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
開發者ID:globocom,項目名稱:groot,代碼行數:20,代碼來源:RedisConfiguration.java

示例2: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    String default_host = "localhost";
    int port = 6379;
    String host = null;
    { // setup the host using the env vars
        host = System.getenv().get(SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY);
        if (host == null) {
            logger.error(String.format("FAILED to find env var [%s]", SELDON_CLUSTER_MANAGER_REDIS_HOST_KEY));
            host = default_host;
        }
    }

    logger.info(String.format("setting up connection factory, host[%s] port[%d]", host, port));
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(host);
    jedisConnectionFactory.setPort(port);
    jedisConnectionFactory.setPassword("");
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setPoolConfig(new JedisPoolConfig());
    return jedisConnectionFactory;
}
 
開發者ID:SeldonIO,項目名稱:seldon-core,代碼行數:23,代碼來源:RedisConfig.java

示例3: connectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的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: jedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisHost);
    factory.setPort(redisPort);
    factory.setUsePool(true);
    if(StringUtils.isNotBlank(password)) {
    	factory.setPassword(password);
    }
    JedisPoolConfig config = new JedisPoolConfig();
    if(maxIdle!=null) {
    	config.setMaxIdle(maxIdle);
    }
    factory.setPoolConfig(config);
    return factory;
}
 
開發者ID:panguixiang,項目名稱:my-spring-cache-redis,代碼行數:17,代碼來源:SpringConfig.java

示例5: jedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory jedisConnectionFactory () {
    JedisConnectionFactory jedisFactory = new JedisConnectionFactory();
    jedisFactory.setPassword(redisPassword);
    jedisFactory.setHostName(redisHost);
    jedisFactory.setPort(redisPort);
    jedisFactory.setUsePool(true);
    return jedisFactory;
}
 
開發者ID:veritasware,項目名稱:neto,代碼行數:10,代碼來源:RedisConfig.java

示例6: jedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisProperties.getHost());
    factory.setPort(redisProperties.getPort());
    factory.setPassword(redisProperties.getPassword());
    factory.setUsePool(true);
    return factory;
}
 
開發者ID:ugouku,項目名稱:shoucang,代碼行數:10,代碼來源:RedisConfiguration.java

示例7: createJedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的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

示例8: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的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: connectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public RedisConnectionFactory connectionFactory() {
  JedisConnectionFactory factory = new JedisConnectionFactory();
  factory.setHostName(redisHost);
  factory.setPort(redisPort);
  factory.setUsePool(true);
  return factory;
}
 
開發者ID:dembros,項目名稱:containerized,代碼行數:9,代碼來源:DemoApplication.java

示例10: getRedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的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;
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:17,代碼來源:RedisConfig.java

示例11: jedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName("localhost");
    factory.setPort(6379);
    factory.setUsePool(true);
    return factory;
}
 
開發者ID:cf-platform-eng,項目名稱:vrealize-service-broker,代碼行數:9,代碼來源:TestConfig.java

示例12: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setHostName(host);
    jedisConnectionFactory.setPort(port);
    return jedisConnectionFactory;
}
 
開發者ID:IBYoung,項目名稱:vert.3x-gateway,代碼行數:9,代碼來源:RedisConfig.java

示例13: jedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(System.getProperty(Constants.REDIS_HOST_NAME, Constants.LOCALHOST));
    factory.setPort(Integer.parseInt(System.getProperty(Constants.REDIS_PORT)));
    factory.setUsePool(true);
    return factory;
}
 
開發者ID:muhamadto,項目名稱:CoffeeBeansRest,代碼行數:9,代碼來源:RedisCachingConfig.java

示例14: jedisConnFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory jedisConnFactory(){
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setHostName(host);
	factory.setPort(port);
	factory.setPassword(passwd);
	factory.setUsePool(true);
	return factory;
}
 
開發者ID:qwefgh90,項目名稱:ChangTalk,代碼行數:10,代碼來源:Application.java

示例15: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //導入方法依賴的package包/類
@Bean
public JedisConnectionFactory redisConnectionFactory() {
	JedisConnectionFactory res = new JedisConnectionFactory();
	res.setUsePool(true);
	res.setHostName(redisHostname);
	res.setPort(redisPort);
	return res;
}
 
開發者ID:sshcherbakov,項目名稱:cf-service-tester,代碼行數:9,代碼來源:StandaloneConfig.java


注:本文中的org.springframework.data.redis.connection.jedis.JedisConnectionFactory.setUsePool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。