app-cache.xml 1.71 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
<?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:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
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-4.0.xsd">

<cache:annotation-driven />

<bean name="cacheManager" class="com.lyms.spring.redis.ExtendedRedisCacheManager">
<constructor-arg name="redisOperations" ref="redisTemplate" />
<constructor-arg name="cacheNames">
<set>
<value>hospital.conf:highrisk</value>
<value>hospital.conf:diagnose</value>
</set>
</constructor-arg>
<!-- 默认缓存名字 -->
<property name="defaultCacheName" value="hospital.defaultCache" />
<!-- 是否在容器启动时初始化 -->
<property name="loadRemoteCachesOnStartup" value="true" />
<!-- 是否使用前缀 -->
<property name="usePrefix" value="true" />
<!-- 前缀命名,仅当usePrefix为true时才生效 -->
<property name="cachePrefix">
<bean class="org.springframework.data.redis.cache.DefaultRedisCachePrefix">
<constructor-arg name="delimiter" value=":" />
</bean>
</property>
<!-- 缓存名字和有效期的分隔符 -->
<property name="separator" value="#" />
<!-- 默认有效期1h -->
<property name="defaultExpiration" value="3600" />
<!-- 多个缓存有效期,一般的单个工程可以省略此项 -->
<!-- <property name="expires">
<map>
<entry key="user" value="1800" />
</map>
</property> -->
</bean>

</beans>