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

spring.redis.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c"
	xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd">
	<!-- jedis 配置-->
    <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig" >
        <!--最小空闲数-->  
        <property name="minIdle" value="${redis.minIdle}" />
        <!--最大空闲数-->  
        <property name="maxIdle" value="${redis.maxIdle}" />
        <!--最大连接数-->  
        <property name="maxTotal" value="${redis.maxTotal}" />
        <!--最大建立连接等待时间-->  
        <property name="maxWaitMillis" value="${redis.maxWaitMillis}" />
        <!--是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个-->  
        <property name="testOnBorrow" value="${redis.testOnBorrow}" />  
    </bean >
	<!-- redisCluster配置 -->
	<!-- <bean id="redisClusterConfiguration" class="org.springframework.data.redis.connection.RedisClusterConfiguration">
		<constructor-arg name="propertySource">
        	<bean id="resourcePropertySource" class="org.springframework.core.io.support.ResourcePropertySource"
		        c:name="redis.properties" c:resource="classpath*:config/system.properties"/>
		    </bean>
		</constructor-arg>
	</bean>
	<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
		c:cluster-config-ref="redisClusterConfiguration" c:pool-config-ref="jedisPoolConfig" p:timeout="${redis.timeout}"
		p:password="${redis.password}" /> -->
	<!-- redis服务器中心 -->
	<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
		p:host-name="${redis.host}" p:port="${redis.port}" p:password="${redis.password}"
		p:pool-config-ref="jedisPoolConfig" p:timeout="${redis.timeout}" />
	<!-- 缓存序列化方式 -->
	<bean id="keySerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer" />
	<bean id="valueSerializer" class="org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer" />
	<!-- 缓存 -->
	<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
		<property name="connectionFactory" ref="jedisConnectionFactory" />
		<property name="enableTransactionSupport" value="true" />
		<property name="keySerializer" ref="keySerializer" />
		<property name="valueSerializer" ref="valueSerializer" />
		<property name="hashKeySerializer" ref="keySerializer" />
		<property name="hashValueSerializer" ref="valueSerializer" />
	</bean>
	<bean class="com.wichell.core.support.cache.RedisHelper" >
		<property name="redisTemplate" ref="redisTemplate" />
	</bean>
	<!-- 缓存管理 -->
	<bean id="redisCacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
		<constructor-arg index="0" ref="redisTemplate" />
		<property name="transactionAware" value="true" />
		<property name="defaultExpiration" value="${redis.expiration}" />
	</bean>
</beans>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy