Java Code Examples for org.springframework.data.redis.connection.jedis.JedisConnectionFactory#setHostName()

The following examples show how to use org.springframework.data.redis.connection.jedis.JedisConnectionFactory#setHostName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisApplication.java    From redis-admin with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: RedisConfig.java    From demo-project with MIT License 6 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
    logger.info("jedisConnectionFactory:初始化了");
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxIdle(maxIdle);
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMaxTotal(maxActive);
    //链接耗尽时是否阻塞,默认true
    config.setBlockWhenExhausted(true);
    //是否启用pool的jmx管理功能,默认true
    config.setJmxEnabled(true);
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setPoolConfig(config);
    factory.setHostName(host);
    factory.setPort(port);
    factory.setPassword(password);
    factory.setDatabase(database);
    factory.setTimeout(timeout);
    return factory;
}
 
Example 3
Source File: RedisConfiguration.java    From spring-boot-with-multi-redis with MIT License 5 votes vote down vote up
@Primary
@Bean(name = "userRedisConnectionFactory")
public RedisConnectionFactory userRedisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(userRedisProperty.getHost());
    redisConnectionFactory.setPort(userRedisProperty.getPort());
    redisConnectionFactory.setDatabase(userRedisProperty.getDatabase());
    return redisConnectionFactory;
}
 
Example 4
Source File: RedisConfig.java    From Project with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisCF() {
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setHostName("192.168.198.129");
	factory.setPassword("123456");
	return factory;
}
 
Example 5
Source File: JedisLockProviderIntegrationTest.java    From ShedLock with Apache License 2.0 5 votes vote down vote up
private static RedisConnectionFactory createJedisConnectionFactory() {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(HOST);
    jedisConnectionFactory.setPort(PORT);
    jedisConnectionFactory.afterPropertiesSet();
    return jedisConnectionFactory;
}
 
Example 6
Source File: RedisCacheConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(host);
    factory.setPort(port);
    return factory;
}
 
Example 7
Source File: RedisConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory cf = new JedisConnectionFactory();
    cf.setHostName(getHost());
    cf.setPort(getPort());
    cf.afterPropertiesSet();
    return cf;
}
 
Example 8
Source File: CacheService.java    From springboot-learn with MIT License 5 votes vote down vote up
/**
 * redis 数据库连接池
 *
 * @return
 */

@Bean
public JedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisConn.getHost());
    factory.setPort(redisConn.getPort());
    factory.setPassword(redisConn.getPassword());
    factory.setTimeout(redisConn.getTimeout()); // 设置连接超时时间
    factory.setDatabase(redisConn.getDatabase());
    return factory;
}
 
Example 9
Source File: RedisConfig.java    From Resource with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory()
{
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(env.getProperty("redis.host").trim());
    jedisConnectionFactory.setPort(Integer.parseInt(env.getProperty("redis.port").trim()));
    jedisConnectionFactory.setPassword(env.getProperty("redis.password").trim());
    jedisConnectionFactory.setDatabase(Integer.parseInt(env.getProperty("redis.database").trim()));
    jedisConnectionFactory.setUsePool(true);
    jedisConnectionFactory.setPoolConfig(jedisPoolConfig);
    return jedisConnectionFactory;
}
 
Example 10
Source File: BootmonServerRedisConfig.java    From boot-mon with Apache License 2.0 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory jedisConFactory = new JedisConnectionFactory();
    jedisConFactory.setHostName(host);
    jedisConFactory.setPort(port);
    return jedisConFactory;
}
 
Example 11
Source File: RedisConfiguration.java    From heimdall with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link JedisConnectionFactory}.
 * 
 * @return {@link JedisConnectionFactory}
 */
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
     
     JedisConnectionFactory factory = new JedisConnectionFactory();
     
     factory.setHostName(property.getRedis().getHost());
     factory.setPort(property.getRedis().getPort());
     factory.setUsePool(true);
     factory.setPoolConfig(jediPoolConfig());
     return factory;
}
 
Example 12
Source File: RedisConfiguration.java    From spring-boot-with-multi-redis with MIT License 5 votes vote down vote up
@Bean(name = "roleRedisConnectionFactory")
public RedisConnectionFactory roleRedisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(roleRedisProperty.getHost());
    redisConnectionFactory.setPort(roleRedisProperty.getPort());
    redisConnectionFactory.setDatabase(roleRedisProperty.getDatabase());
    return redisConnectionFactory;
}
 
Example 13
Source File: RedisConfig.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
	connectionFactory.setHostName("192.168.1.103");
	connectionFactory.setUsePool(true);
	return connectionFactory;
}
 
Example 14
Source File: AppConfig.java    From Redis-4.x-Cookbook with MIT License 5 votes vote down vote up
@Bean
   JedisConnectionFactory jedisConnectionFactory(){
	JedisConnectionFactory factory = new JedisConnectionFactory();
	factory.setHostName(redisHost);
	factory.setPort(redisPort);
	factory.setUsePool(true);
	return factory;
}
 
Example 15
Source File: CacheService.java    From SpringBoot-Dubbo-Docker-Jenkins with Apache License 2.0 5 votes vote down vote up
/**
 * redis 数据库连接池
 * @return
 */

@Bean
public JedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisConn.getHost());
    factory.setPort(redisConn.getPort());
    factory.setTimeout(redisConn.getTimeout()); // 设置连接超时时间
    return factory;
}
 
Example 16
Source File: JedisLockProviderIntegrationTest.java    From ShedLock with Apache License 2.0 5 votes vote down vote up
private static RedisConnectionFactory createJedisConnectionFactory() {
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(HOST);
    jedisConnectionFactory.setPort(PORT);
    jedisConnectionFactory.afterPropertiesSet();
    return jedisConnectionFactory;
}
 
Example 17
Source File: SessionConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@Primary
public JedisConnectionFactory connectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(properties.getProperty("spring.redis.host","localhost"));
    factory.setPort(properties.getProperty("spring.redis.port", Integer.TYPE,6379));
    factory.afterPropertiesSet();
    factory.setUsePool(true);
    return factory;
}
 
Example 18
Source File: RedisConfiguration.java    From java-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
	JedisConnectionFactory connectionFactory = new JedisConnectionFactory(jedisPoolConfig());
	connectionFactory.setHostName(hostName);
	connectionFactory.setPort(Integer.parseInt(port));
	connectionFactory.setPassword(password);
	return connectionFactory;
}
 
Example 19
Source File: RedisContextConfig.java    From onetwo with Apache License 2.0 5 votes vote down vote up
@Bean
  @OnMissingBean(JedisConnectionFactory.class)
  public JedisConnectionFactory securityRedisConnectionFactory() throws Exception {
int port = securityConfig.getRedis().getPort();
String hostName = securityConfig.getRedis().getHostName();
JedisConnectionFactory jf = new JedisConnectionFactory();
jf.setPort(port);
jf.setHostName(hostName);
SpringUtils.newBeanWrapper(jf).setPropertyValues(securityConfig.getRedis());
if(securityConfig.getRedis().getPool()!=null){
	jf.setPoolConfig(securityConfig.getRedis().getPool());
}
return jf;
  }
 
Example 20
Source File: KyRedisConfig.java    From ClusterDeviceControlPlatform with MIT License 4 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(DbSetting.HOST);
    return factory;
}