springdataRedis连接redis集群

springdataRedis连接redis集群

配置文件:

"1.0" encoding="UTF-8"?> 
"http://www.springframework.org/schema/beans" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
  xmlns:context="http://www.springframework.org/schema/context" 
  xsi:schemaLocation="http://www.springframework.org/schema/beans   
            http://www.springframework.org/schema/beans/spring-beans.xsd   
            http://www.springframework.org/schema/context   
            http://www.springframework.org/schema/context/spring-context.xsd">  
  
      
    "true" location="classpath:properties/redis-cluster-config.properties" />  
    "redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration">  
        "maxRedirects" value="${redis.maxRedirects}">  
        "clusterNodes">  
            <set>  
                class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host1}">  
                    "port" value="${redis.port1}">  
                  
                class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host2}">  
                    "port" value="${redis.port2}">  
                  
                    class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host3}">  
                    "port" value="${redis.port3}">  
                  
                class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host4}">  
                    "port" value="${redis.port4}">  
                  
                class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host5}">  
                    "port" value="${redis.port5}">  
                  
                class="org.springframework.data.redis.connection.RedisClusterNode">  
                    "host" value="${redis.host6}">  
                    "port" value="${redis.port6}">  
                  
            set>  
          
      
    "jedisPoolConfig"   class="redis.clients.jedis.JedisPoolConfig">  
            "maxIdle" value="${redis.maxIdle}" />   
            "maxTotal" value="${redis.maxTotal}" />   
      
    "jeidsConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"  >  
        ref="redisClusterConfiguration" />  
        ref="jedisPoolConfig" />  
        
    "redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">  
        "connectionFactory" ref="jeidsConnectionFactory" />  
      

redis-cluster-config.properties:

#cluster configuration
redis.host1=192.168.230.133
redis.port1=7001

redis.host2=192.168.230.133
redis.port2=7002

redis.host3=192.168.230.133
redis.port3=7003

redis.host4=192.168.230.133
redis.port4=7004

redis.host5=192.168.230.133
redis.port5=7005

redis.host6=192.168.230.133
redis.port6=7006

redis.maxRedirects=3
redis.maxIdle=100
redis.maxTotal=600

开发中并不需要注意这些内容,只是需要注意开发逻辑即可

posted @ 2019-02-13 20:09 动手的程序员 阅读( ...) 评论( ...) 编辑 收藏

你可能感兴趣的:(springdataRedis连接redis集群)