• redisTemplate


        <!-- redis属性配置 -->
        <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
            <property name="maxTotal" value="${redis.pool.maxTotal}" />
            <property name="maxIdle" value="${redis.pool.maxIdle}" />
            <property name="numTestsPerEvictionRun" value="${redis.pool.numTestsPerEvictionRun}" />
            <property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}" />
            <property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}" />
            <property name="softMinEvictableIdleTimeMillis" value="${redis.pool.softMinEvictableIdleTimeMillis}" />
            <property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}" />
            <property name="testOnBorrow" value="${redis.pool.testOnBorrow}" />
        </bean>
    
        <!-- redis集群配置 哨兵模式 -->
        <bean id="sentinelConfiguration" class="org.springframework.data.redis.connection.RedisSentinelConfiguration">
            <property name="master">
                <bean class="org.springframework.data.redis.connection.RedisNode">
                    <!--这个值要和Sentinel中指定的master的值一致,不然启动时找不到Sentinel会报错的-->
                    <property name="name" value="mymaster"></property>
                </bean>
            </property>
            <!--记住了,这里是指定Sentinel的IP和端口,不是Master和Slave的-->
            <property name="sentinels">
                <set>
                    <bean class="org.springframework.data.redis.connection.RedisNode">
                        <constructor-arg name="host" value="${redis.sentinel.host1}"></constructor-arg>
                        <constructor-arg name="port" value="${redis.sentinel.port1}"></constructor-arg>
                    </bean>
                    <bean class="org.springframework.data.redis.connection.RedisNode">
                        <constructor-arg name="host" value="${redis.sentinel.host2}"></constructor-arg>
                        <constructor-arg name="port" value="${redis.sentinel.port2}"></constructor-arg>
                    </bean>
                </set>
            </property>
        </bean>
        <bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.RedisConnectionFactory">
            <constructor-arg name="sentinelConfig" ref="sentinelConfiguration"></constructor-arg>
            <constructor-arg name="poolConfig" ref="jedisPoolConfig"></constructor-arg>
        </bean>
        <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
            <property name="connectionFactory" ref="redisConnectionFactory"></property>
        </bean>
        <!-- 缓存管理器 -->
        <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
            <constructor-arg ref="redisTemplate" />
        </bean>
        
  • 相关阅读:
    [转]Request Control Introduce
    [转]How to set the control word of FPU in delphi
    Delphi消息分发机制
    Delphi Handle Exception
    python 简单图像处理(13) 二值图腐蚀和膨胀,开运算、闭运算
    如何在Linux下实现50万并发
    转载 google hack
    Linux 网卡如何支持TSO GSO指南
    收藏:网口协商
    AVR地址空间
  • 原文地址:https://www.cnblogs.com/yy123/p/7132632.html
Copyright © 2020-2023  润新知