spring-cache.xml 2.07 KB
<?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"
	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.1.xsd">

	<cache:annotation-driven mode="aspectj" cache-manager="cacheManager" proxy-target-class="true" order="1"/>
	<bean id="cacheManager" class="org.springframework.cache.support.CompositeCacheManager">
		<property name="cacheManagers">
		<list>
			<ref bean="local"/>
			<ref bean="center"/>
		</list>
		</property>
		<property name="fallbackToNoOpCache" value="true"/>
	</bean>
	<!-- 
	<bean id="local" class="org.springframework.cache.guava.GuavaCacheManager">
	    <property name="cacheSpecification" value="maximumSize=2000,concurrencyLevel=2,expireAfterAccess=3600s,expireAfterWrite=72000s" />
	    <property name="cacheNames">
	        <list>
	            <value>ACT</value>
	            <value>API</value>
	            <value>RAK</value>
	            <value>TPL</value>
	            <value>CNF</value>
	        </list>
	    </property>
	</bean>
	 -->
	<!--ehcache-->
	<bean id="local" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="ehcacheManagerFactory"/>
    </bean>
    <bean id="ehcacheManagerFactory" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="classpath:cache/ehcache.xml"/>
    </bean>
    
	<bean id="center" class="org.springframework.data.redis.cache.RedisCacheManager">
		<constructor-arg>
		<ref bean="redisTemplate"/>
		</constructor-arg>
		<property name="cacheNames">
			<set>
			<value>SIT_API</value>
			<value>GZH_API</value>
			<value>CST</value>
			<value>CPN</value>
			<value>EVT</value>
			</set>
		</property>
		<property name="defaultExpiration">
			<value>3600</value>
		</property>
	</bean>
</beans>