spring+mybatis+redis整合后如何动态设置失效时间

 spring+mybatis+redis整合后redis支持设置不同缓存的失效时间,

看帖子评论找到的方法:帖子地址:http://hbxflihua.iteye.com/blog/2320584

<!-- 配置RedisCacheManager -->
 <bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager"> 
     <constructor-arg name="redisOperations" ref="redisTemplate" />
  <property name="defaultExpiration" value="${redis.expiration}"/>
        <property name="expires"> 
            <util:map> 
                <entry value="180" key="selectUserById"/> 
                <entry value="180000" key="menuByUrl"/> 
            </util:map> 
        </property> 
 </bean>

需要引用:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans   
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
           http://www.springframework.org/schema/aop   
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
           http://www.springframework.org/schema/context   
           http://www.springframework.org/schema/context/spring-context-3.0.xsd
           http://www.springframework.org/schema/util 
           http://www.springframework.org/schema/util/spring-util-3.0.xsd
           "> 

原文地址:https://www.cnblogs.com/zypu/p/6593820.html