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

The following examples show how to use org.springframework.data.redis.connection.jedis.JedisConnectionFactory#setPort() . 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: RedisConfig.java    From springBoot-study with Apache License 2.0 6 votes vote down vote up
/**
 * 配置工厂
 */
@Bean
public JedisConnectionFactory JedisConnectionFactory(JedisPoolConfig jedisPoolConfig) {
	JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(jedisPoolConfig);
	/*
	  *    设置密码,如果为空,则不设置
	  *  可在 redis.conf 文件中设置: requirepass 密码
	 */
	
	if (redispwd == null || redispwd.length() == 0) {
		jedisConnectionFactory.setPassword(redispwd);
	}
	jedisConnectionFactory.setHostName(host);
	jedisConnectionFactory.setPort(port);
	return jedisConnectionFactory;
}
 
Example 2
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 3
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 4
Source File: RedisConfiguration.java    From WTFDYUM with Apache License 2.0 5 votes vote down vote up
@Bean
public RedisConnectionFactory redisConnectionFactory() {
    final JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
    jedisConnectionFactory.setHostName(env.getProperty("wtfdyum.redis.server"));
    jedisConnectionFactory.setPort(env.getProperty("wtfdyum.redis.port", Integer.class));
    jedisConnectionFactory.setDatabase(env.getProperty("wtfdyum.redis.database", Integer.class));
    return jedisConnectionFactory;
}
 
Example 5
Source File: RedisConfiguration.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setHostName(redisProperties.getHost());
    factory.setPort(redisProperties.getPort());
    factory.setPassword(redisProperties.getPassword());
    factory.setUsePool(true);
    return factory;
}
 
Example 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
Source File: RedisConfiguration.java    From heimdall with Apache License 2.0 5 votes vote down vote up
/**
 * Configures and returns a {@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 17
Source File: Application.java    From spring-microservices-in-action with Apache License 2.0 5 votes vote down vote up
/**
 * Build the connection to Redis server.
 * 
 * @return  The object of {@code JedisConnectionFactory}.
 */
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
    JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
    jedisConnFactory.setHostName(serviceConfig.getRedisServer());
    jedisConnFactory.setPort(serviceConfig.getRedisPort());
    return jedisConnFactory;
}
 
Example 18
Source File: ApplicationConfig.java    From docker-kubernetes-by-example-java with Apache License 2.0 5 votes vote down vote up
@Bean
JedisConnectionFactory jedisConnectionFactory() throws URISyntaxException {
  URI uri = new URI(redisEndpoint);
  JedisConnectionFactory factory = new JedisConnectionFactory();
  factory.setHostName(uri.getHost());
  factory.setPort(uri.getPort());

  return factory;
}
 
Example 19
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 20
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;
}