spring-redis.xml

<?xml version="1.0" encoding="UTF-8"?>














<!-- redis sentinel 配置 客户端Redis-->
<bean id="redisSentinelForClient" class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
    <!-- cluster name -->
    <property name="master">
        <bean class="org.springframework.data.redis.connection.RedisNode">
            <property name="name" value="${redis_clusterName}" />
        </bean>
    </property>
    <!-- sentinel信息 -->
    <property name="sentinels">
        <set>
            <bean class="org.springframework.data.redis.connection.RedisNode">
                <constructor-arg index="0" value="${redis_host}"/>
                <constructor-arg index="1" value="${redis_port}"/>
            </bean>
        </set>
    </property>
</bean>

<!-- 连接工厂配置 -->
<bean id="clientJedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <!-- redis sentinel配置 -->
    <constructor-arg ref="redisSentinelForClient"/>
    <!-- jedis 连接池配置 -->
    <constructor-arg ref="jedisPoolConfig" />
</bean>

<!-- 数据模板配置 -->
<bean id="clientRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <property name="connectionFactory" ref="clientJedisConnFactory"/>
</bean>


<!-- redis sentinel 配置 交易引擎Redis-->
<bean id="redisSentinelForTransCenter" class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
    <!-- cluster name -->
    <property name="master">
        <bean class="org.springframework.data.redis.connection.RedisNode">
            <property name="name" value="${redisRandom_clusterName}" />
        </bean>
    </property>
    <!-- sentinel信息 -->
    <property name="sentinels">
        <set>
            <bean class="org.springframework.data.redis.connection.RedisNode">
                <constructor-arg index="0" value="${redisRandom_host52}"/>
                <constructor-arg index="1" value="${redisRandom_port}"/>
            </bean>
        </set>
    </property>
</bean>

<!-- 连接工厂配置 -->
<bean id="transCenterJedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
    <!-- redis sentinel配置 -->
    <constructor-arg ref="redisSentinelForTransCenter"/>
    <!-- jedis 连接池配置 -->
    <constructor-arg ref="jedisPoolConfig" />
</bean>

<!-- 数据模板配置 -->
<bean id="transCenterRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
    <property name="connectionFactory" ref="transCenterJedisConnFactory"/>
</bean>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值