All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.simple-spring-memcached.spring-cache-integration-test.3.0.1.source-code.application-context.xml Maven / Gradle / Ivy

Go to download

Sample project using integration with Spring 3.1 cache abstraction and xmemcached provider

There is a newer version: 4.1.3
Show newest version
<?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:context="http://www.springframework.org/schema/context" xmlns:cache="http://www.springframework.org/schema/cache"
	xsi:schemaLocation="
		   http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.1.xsd
           http://www.springframework.org/schema/cache 
           http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">

	<cache:annotation-driven />

	<context:annotation-config />
	<context:component-scan base-package="com.google.code.ssm.spring.test" />

	<bean name="cacheManager" class="com.google.code.ssm.spring.SSMCacheManager">
		<property name="caches">
			<set>
				<bean class="com.google.code.ssm.spring.SSMCache">
					<constructor-arg name="cache" index="0" ref="userCache" />
					<!-- 5 minutes -->
					<constructor-arg name="expiration" index="1" value="300" />
					<!-- @CacheEvict(..., "allEntries" = true) doesn't work -->
					<constructor-arg name="allowClear" index="2" value="false" />
				</bean>
				<bean class="com.google.code.ssm.spring.SSMCache">
					<constructor-arg name="cache" index="0" ref="clearableCache" />
					<!-- 5 minutes -->
					<constructor-arg name="expiration" index="1" value="300" />
					<!-- @CacheEvict(..., "allEntries" = true) works -->
					<constructor-arg name="allowClear" index="2" value="true" />
				</bean>
			</set>
		</property>
	</bean>

	<!-- easy way to test different types of serialization mechanizm by passing it as system property (-Dssm.provider=JSON) -->
	<bean name="defaultSerializationTypeAsString" class="java.lang.String">
		<constructor-arg value="#{systemProperties['ssm.defaultSerializationType']?:'JSON'}" />
	</bean>

	<bean name="userCache" class="com.google.code.ssm.CacheFactory">
		<property name="cacheName" value="userCache" />
		<property name="cacheClientFactory" ref="cacheClientFactory"/>
		<property name="addressProvider">
			<bean class="com.google.code.ssm.config.DefaultAddressProvider">
				<property name="address" value="127.0.0.1:11211" />
			</bean>
		</property>
		<property name="configuration">
			<bean class="com.google.code.ssm.providers.CacheConfiguration">
				<property name="consistentHashing" value="true" />
			</bean>
		</property>
		<property name="defaultSerializationType"
			value="#{T(com.google.code.ssm.api.format.SerializationType).valueOf(@defaultSerializationTypeAsString)}" />
	</bean>

	<bean name="clearableCache" class="com.google.code.ssm.CacheFactory">
		<property name="cacheName" value="clearableCache" />
		<property name="cacheClientFactory" ref="cacheClientFactory"/>
		<property name="addressProvider">
			<bean class="com.google.code.ssm.config.DefaultAddressProvider">
				<property name="address" value="127.0.0.1:11212" />
			</bean>
		</property>
		<property name="configuration">
			<bean class="com.google.code.ssm.providers.CacheConfiguration">
				<property name="consistentHashing" value="true" />
			</bean>
		</property>
		<property name="defaultSerializationType"
			value="#{T(com.google.code.ssm.api.format.SerializationType).valueOf(@defaultSerializationTypeAsString)}" />
	</bean>
	
	
	<!-- flush all data from memcached before starting tests -->
	<bean id="flushUserCache" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
		<property name="targetObject" ref="userCache" />
		<property name="targetMethod" value="flush" />
	</bean>

	<!-- flush all data from memcached before starting tests -->
	<bean id="flushClearableCache" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
		<property name="targetObject" ref="clearableCache" />
		<property name="targetMethod" value="flush" />
	</bean>
	
	<beans profile="xmemcached">
		<bean name="cacheClientFactory" class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl" />
	</beans>
	
	<beans profile="spymemcached">
		<bean name="cacheClientFactory" class="com.google.code.ssm.providers.spymemcached.MemcacheClientFactoryImpl" />
	</beans>

</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy