spring-config-redis.xml 1.84 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:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    		http://www.springframework.org/schema/beans/spring-beans.xsd
       		http://www.springframework.org/schema/context 
     		http://www.springframework.org/schema/context/spring-context.xsd"
	default-autowire="byName">

	<context:component-scan base-package="com.dili.titan.redis" />

	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
		<property name="maxIdle" value="6"></property>
		<property name="minEvictableIdleTimeMillis" value="300000"></property>
		<property name="numTestsPerEvictionRun" value="3"></property>
		<property name="timeBetweenEvictionRunsMillis" value="60000"></property>
	</bean>

	<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
		destroy-method="destroy">
		<property name="poolConfig" ref="jedisPoolConfig"></property>
<!-- 		<property name="hostName" value="http://${redis.url}/"></property> -->
		<property name="hostName" value="${dili_titan.redis.url}"></property>
		<property name="port" value="6379"></property>
		<property name="timeout" value="15000"></property>
		<property name="usePool" value="true"></property>
	</bean>

	<bean id="jedisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
		<property name="connectionFactory" ref="jedisConnectionFactory"></property>
		<property name="keySerializer">
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
		<property name="valueSerializer">
			<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
		</property>
	</bean>
</beans>