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


Java JedisConnectionFactory.setPassword方法代码示例

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


在下文中一共展示了JedisConnectionFactory.setPassword方法的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
@RefreshScope
public RedisConnectionFactory redisConnectionFactory() {
    final RedisTicketRegistryProperties redis = casProperties.getTicket().getRegistry().getRedis();
    final JedisPoolConfig poolConfig = redis.getPool() != null ? jedisPoolConfig() : new JedisPoolConfig();

    final JedisConnectionFactory factory = new JedisConnectionFactory(poolConfig);
    factory.setHostName(redis.getHost());
    factory.setPort(redis.getPort());
    if (redis.getPassword() != null) {
        factory.setPassword(redis.getPassword());
    }
    factory.setDatabase(redis.getDatabase());
    if (redis.getTimeout() > 0) {
        factory.setTimeout(redis.getTimeout());
    }
    return factory;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:RedisTicketRegistryConfiguration.java

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

示例4: afterPropertiesSet

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    int redisCount = Integer.parseInt(RedisProperties.getPropertie("redis.count").toString());
    factories = new ArrayList<JedisConnectionFactory>(redisCount);
    for (int i = 0; i < redisCount; i++) {
        int dbSize = 1;
        Object dbSizeObj = RedisProperties.getPropertie("redis.db.size" + i);
        if (dbSizeObj != null) {
            dbSize = Integer.valueOf(dbSizeObj.toString());
        }
        for (int j = 0; j < dbSize; j++) {
            JedisConnectionFactory factory = new JedisConnectionFactory(sentinelConfig,poolConfig);
            factory.setHostName(RedisProperties.getPropertie("redis.host" + i).toString());
            factory.setPort(Integer.parseInt(RedisProperties.getPropertie("redis.port" + i).toString()));
            factory.setPassword(RedisProperties.getPropertie("reids.passwd" + i).toString());
            factory.setTimeout(Integer.parseInt(RedisProperties.getPropertie("redis.timeout").toString()));
            factory.setDatabase(j);
            // 执行必要方法
            factory.afterPropertiesSet();
            factories.add(factory);
        }
    }
}
 
开发者ID:Fourwenwen,项目名称:consistent-hashing-redis,代码行数:24,代码来源:HwRedisConnectionFactory.java

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

示例6: createRedisConnection

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected void createRedisConnection(String name, String host, int port, String password) {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.setHostName(host);
	connectionFactory.setPort(port);
	if(!StringUtils.isEmpty(password))
		connectionFactory.setPassword(password);
	connectionFactory.afterPropertiesSet();
	RedisTemplate redisTemplate = new MyStringRedisTemplate();
	redisTemplate.setConnectionFactory(connectionFactory);
	redisTemplate.afterPropertiesSet();
	RedisApplication.redisTemplatesMap.put(name, redisTemplate);
	
	Map<String, Object> redisServerMap = new HashMap<String, Object>();
	redisServerMap.put("name", name);
	redisServerMap.put("host", host);
	redisServerMap.put("port", port);
	redisServerMap.put("password", password);
	RedisApplication.redisServerCache.add(redisServerMap);
	
	initRedisKeysCache(redisTemplate, name);
	
	RedisZtreeUtil.initRedisNavigateZtree(name);
}
 
开发者ID:mauersu,项目名称:redis-admin,代码行数:24,代码来源:RedisApplication.java

示例7: configureConnectionFromUrl

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
private void configureConnectionFromUrl(JedisConnectionFactory factory) {
	String url = this.properties.getUrl();
	if (url.startsWith("rediss://")) {
		factory.setUseSsl(true);
	}
	try {
		URI uri = new URI(url);
		factory.setHostName(uri.getHost());
		factory.setPort(uri.getPort());
		if (uri.getUserInfo() != null) {
			String password = uri.getUserInfo();
			int index = password.lastIndexOf(":");
			if (index >= 0) {
				password = password.substring(index + 1);
			}
			factory.setPassword(password);
		}
	}
	catch (URISyntaxException ex) {
		throw new IllegalArgumentException("Malformed 'spring.redis.url' " + url,
				ex);
	}
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:24,代码来源:ShiroRedisAutoConfiguration.java

示例8: createJedisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
/**
 * 建立
 * 
 * i=0, port(6379)
 * 
 * i=1, port(6379)+i=6380
 * 
 * @param i
 * @param jedisPoolConfig
 * @return
 */
protected JedisConnectionFactory createJedisConnectionFactory(int i, JedisPoolConfig jedisPoolConfig)
		throws Exception {
	JedisConnectionFactory result = new JedisConnectionFactory();
	String hostName = extendedProperties.getString(HOSTNAME, DEFAULT_HOSTNAME);
	//
	int port = extendedProperties.getInt(PORT, DEFAULT_PORT);
	port += i;
	LOGGER.info("redis[" + i + "]: " + hostName + ":" + port);
	//
	result.setHostName(hostName);
	result.setPort(port);
	//
	result.setPassword(extendedProperties.getString(PASSWORD, DEFAULT_PASSWORD));
	//
	result.setPoolConfig(jedisPoolConfig);
	result.afterPropertiesSet();
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:31,代码来源:JedisConnectionFactoryFactorySupporter.java

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

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

示例11: connectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
  public RedisConnectionFactory connectionFactory() {
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
jedisConnectionFactory.setHostName(host);
jedisConnectionFactory.setPort(port);
jedisConnectionFactory.setPassword(password);
      return jedisConnectionFactory; 
  }
 
开发者ID:mumuweb,项目名称:mumu-session,代码行数:9,代码来源:RedisConfig.java

示例12: redisConnectionFactory

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
@Bean
public RedisConnectionFactory redisConnectionFactory () {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName( host );
    jedisConnectionFactory.setPort( port );
    jedisConnectionFactory.setPassword( password );
    jedisConnectionFactory.setDatabase( database );
    return jedisConnectionFactory;
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:10,代码来源:RedisConfig.java

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

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

示例15: applyProperties

import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; //导入方法依赖的package包/类
protected final JedisConnectionFactory applyProperties(
		JedisConnectionFactory factory) {
	factory.setHostName(this.properties.getHost());
	factory.setPort(this.properties.getPort());
	if (this.properties.getPassword() != null) {
		factory.setPassword(this.properties.getPassword());
	}
	factory.setDatabase(this.properties.getDatabase());
	if (this.properties.getTimeout() > 0) {
		factory.setTimeout(this.properties.getTimeout());
	}
	return factory;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:RedisAutoConfiguration.java


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