实战 -- Redis2.4.2集成spring3.2.2
redis.host=192.168.1.237 redis.port=6379 redis.pass= redis.timeout=100000 #最大能够保持idel状态的对象数 redis.maxIdle=300 #最大分配的对象数 redis.maxTotal=600 #多长时间检查一次连接池中空闲的连接 redis.timeBetweenEvictionRunsMillis=30000 #空闲连接多长时间后会被收回 redis.minEvictableIdleTimeMillis=30000 #当调用borrow Object方法时,是否进行有效性检查 redis.testOnBorrow=true ########reids编码格式 redis.encode=utf-8 ######缓存过期时间 秒 1000*60*60*24*7 七天 redis.expire=604800000 ####是否开启Redis服务应用 redis.unlock=false
<context:property-placeholder location="classpath:conf/redis.properties" /> <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="timeBetweenEvictionRunsMillis" value="${redis.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${redis.minEvictableIdleTimeMillis}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean> <bean id="jedisPool" class="redis.clients.jedis.JedisPool" destroy-method="destroy"> <constructor-arg ref="jedisPoolConfig" /> <constructor-arg value="${redis.host}" /> <constructor-arg type="int" value="${redis.port}" /> </bean> <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host}" /> <property name="port" value="${redis.port}" /> <property name="password" value="${redis.pass}"/> <property name="timeout" value="${redis.timeout}" /> <property name="poolConfig" ref="jedisPoolConfig" /> <property name="usePool" value="true" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="jedisConnFactory"/> </bean>