zoukankan      html  css  js  c++  java
  • spring+springMVC+mybatis+shiro -- spring-redis.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:c="http://www.springframework.org/schema/c" 
        xmlns:cache="http://www.springframework.org/schema/cache"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/cache
           http://www.springframework.org/schema/cache/spring-cache.xsd">
    
        <!-- 以前项目中的配置,注意需要添加Spring Data Redis等jar包 -->
        <description>redis配置</description>
    
        <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
            <property name="maxTotal" value="${redis.pool.maxTotal}" />
            <property name="maxIdle" value="${redis.pool.maxIdle}" />
            <property name="minIdle" value="${redis.pool.minIdle}"/>
            <property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}" />
            <property name="testOnBorrow" value="${redis.pool.testOnBorrow}" />
            <property name="testOnReturn" value="${redis.pool.testOnReturn}" />
        </bean>
    
        <!-- JedisConnectionFactory -->
        <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
            <property name="hostName" value="${redis.master.ip}" />
            <property name="port" value="${redis.master.port}" />
            <property name="password" value="${redis.master.pass}" />
            <property name="poolConfig" ref="jedisPoolConfig" />
        </bean>
        <bean id="jedisConnectionFactoryForCache" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
            <property name="hostName" value="${redis.master.ip}" />
            <property name="port" value="${redis.master.port}" />
            <property name="password" value="${redis.master.pass}" />
            <property name="poolConfig" ref="jedisPoolConfig" />
            <property name="database" value="${redis.master.database}" />
        </bean>
    
        <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connectionFactory-ref="jedisConnectionFactory">
            <property name="keySerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"></bean>
            </property>
            <property name="valueSerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
            <property name="hashKeySerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
            <property name="hashValueSerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
        </bean>
        <bean id="redisTemplateForCache" class="org.springframework.data.redis.core.RedisTemplate"
            p:connectionFactory-ref="jedisConnectionFactoryForCache">
            <property name="keySerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"></bean>
            </property>
            <property name="valueSerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
            <property name="hashKeySerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
            <property name="hashValueSerializer">
                <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
            </property>
        </bean>
    
        <!--spring cache -->
        <bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:redisOperations-ref="redisTemplate">
            <!-- 默认缓存10分钟 -->
            <property name="defaultExpiration" value="600" />
            <property name="usePrefix" value="true" />
            <!-- cacheName 缓存超时配置,半小时,一小时,一天 -->
            <property name="expires">
                <map key-type="java.lang.String" value-type="java.lang.Long">
                    <entry key="halfHour" value="1800" />
                    <entry key="hour" value="3600" />
                    <entry key="oneDay" value="86400" />
                    <!-- shiro cache keys -->
                    <entry key="authorizationCache" value="1800" />
                    <entry key="authenticationCache" value="1800" />
                    <entry key="activeSessionCache" value="1800" />
                </map>
            </property>
        </bean>
    
        <!-- cache注解,和spring-ehcache.xml中的只能使用一个 -->
        <cache:annotation-driven cache-manager="cacheManager" proxy-target-class="true" />
    </beans>
  • 相关阅读:
    电子辅助的个体化严密控制策略比常规方法更有效地帮助早期RA实现全面控制病情[EULAR2015_THU0122]
    超声和免疫学指标的特征能否反映RA临床缓解的表型?[EULAR2015_THU0121]
    依那西普减量维持过程中RA病人自报病情复发可能预示未来放射学进展[EULAR2015_SAT0147]
    RETRO研究: 持续缓解的RA患者的减量维持方案[EULAR2015_SAT0056]
    OPTIRRA研究: TNF拮抗剂维持期优化减量方案[EULAR2015_SAT0150]
    与时俱进的治疗策略不断提高RA无药缓解机会[EULAR2015_SAT0058]
    雷公藤多甙治疗类风湿关节炎遭质疑
    我的博客今天2岁203天了,我领取了先锋博主徽章
    MyEclipse中最常用的快捷键大全
    MyEclipse无法打开jsp文件(打开是空白的),但是可以打开java文件
  • 原文地址:https://www.cnblogs.com/foreign-student/p/7594104.html
Copyright © 2011-2022 走看看