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

de.simple-spring-memcached.spring-cache-integration-test.3.6.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">
					<qualifier value="userCache"/>
					<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>
				<bean class="com.google.code.ssm.spring.SSMCache">
					<constructor-arg name="cache" index="0" ref="testCache" />
					<!-- 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" ref="clientConfig" />
		<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" ref="clientConfig" />
		<property name="defaultSerializationType"
			value="#{T(com.google.code.ssm.api.format.SerializationType).valueOf(@defaultSerializationTypeAsString)}" />
	</bean>
	
	<bean name="testCache" class="com.google.code.ssm.CacheFactory">
		<property name="cacheName" value="testCache" />
		<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" ref="clientConfig" />
		<property name="defaultSerializationType"
			value="#{T(com.google.code.ssm.api.format.SerializationType).valueOf(@defaultSerializationTypeAsString)}" />
	</bean>

	<beans profile="xmemcached">
		<bean name="cacheClientFactory" class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl" />
		<bean name="clientConfig" class="com.google.code.ssm.providers.CacheConfiguration">
			<property name="consistentHashing" value="true" />
		</bean>
	</beans>

	<beans profile="spymemcached">
		<bean name="cacheClientFactory" class="com.google.code.ssm.providers.spymemcached.MemcacheClientFactoryImpl" />
		<bean name="clientConfig" class="com.google.code.ssm.providers.CacheConfiguration">
			<property name="consistentHashing" value="true" />
		</bean>
	</beans>

	<beans profile="aws-elasticache">
		<bean name="cacheClientFactory" class="com.google.code.ssm.providers.elasticache.MemcacheClientFactoryImpl" />
		<bean name="clientConfig" class="com.google.code.ssm.providers.elasticache.ElastiCacheConfiguration">
				<property name="consistentHashing" value="true" />
				<!-- in local env use static configuration and do not try to fetch configuration of nodes from cluster -->
				<property name="clientMode" value="#{T(net.spy.memcached.ClientMode).Static}" />
			</bean>
	</beans>

</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy