欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

配置多个redis

程序员文章站 2024-01-08 16:40:46
...

配置多个redis客户端

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <bean id="masterJedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
        <property name="hostName" value="10.0.0.2"/>
        <property name="port" value="6379"/>
        <property name="password" value="**************"/>
        <property name="usePool" value="true"/>
    </bean>
    <bean id="slaveJedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
        <property name="hostName" value="10.0.0.3"/>
        <property name="port" value="6379"/>
        <property name="password" value="*************"/>
        <property name="usePool" value="true"/>
    </bean>
    <bean id="masterRedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
        <property name="connectionFactory" ref="masterJedisConnectionFactory"/>
    </bean>
    <bean id="slaveRedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
        <property name="connectionFactory" ref="slaveJedisConnectionFactory"/>
    </bean>
</beans>

 

上一篇:

下一篇: