码迷,mamicode.com
首页 > 编程语言 > 详细

spring配置redis

时间:2017-04-01 12:30:25      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:spool   时间   pre   ns-3   mon   encoding   text   cli   out   

<?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">


<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="300"/> <!-- 控制一个pool可分配多少个jedis实例 -->
<property name="maxIdle" value="100" /> <!-- 控制一个pool最多有多少个状态为idle(空闲)的jedis实例 -->
<property name="maxWaitMillis" value="2000" /> <!-- 表示当borrow一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException -->
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="true"/>
</bean>
<!-- redis的连接池pool,不是必选项:timeout/password -->
<bean id="jedisConnectionFactory"
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.passWord}" />
<property name="poolConfig" ref="jedisPoolConfig" />
</bean>


<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory">
<ref bean="jedisConnectionFactory" />
</property>
</bean>
<!-- 配置springRedis -->
<bean id="springRedis" class="com.inborn.inshop.common.redis.SpringRedis">
<property name="redisKeyPrefix" value="${redis.key.prefix}" />
<property name="stringRedisTemplate">
<ref bean="stringRedisTemplate" />
</property>
</bean>

</beans>

spring配置redis

标签:spool   时间   pre   ns-3   mon   encoding   text   cli   out   

原文地址:http://www.cnblogs.com/lvgg/p/6655359.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!