Spring Redis Settings

Dependency

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-redis</artifactId>
    <version>1.8.4.RELEASE</version>
</dependency>

RedisClusterConfig

@Configuration
public class RedisClusterConfig {

       @Bean
    public RedisConnectionFactory connectionFactory() {

//        List<String> clusterNodes = new ArrayList<String>();
//        clusterNodes.add("192.168.56.102:6379");

//        return new JedisConnectionFactory(new RedisClusterConfiguration(clusterNodes));
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(200);
        jedisPoolConfig.setMaxIdle(200);
        jedisPoolConfig.setMaxWaitMillis(5000);

        JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
        jedisConnectionFactory.setHostName("192.168.56.101");
        jedisConnectionFactory.setPort(6379);
        jedisConnectionFactory.setPoolConfig(jedisPoolConfig);

        return jedisConnectionFactory;
    }

    @Bean
    public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory connectionFactory) {
        return new StringRedisTemplate(connectionFactory);
    }
}

results matching ""

    No results matching ""