Redis配置文件(自用)
#Redis配置文件(自用)
Maven坐标
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
- 1
- 2
- 3
- 4
- 5
配置文件
<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!--Jedis连接池的相关配置-->
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<!--最大活动对象-->
<property name="maxTotal">
<value>200</value>
</property>
<!--最大保持idle数-->
<property name="maxIdle">
<value>50</value>
</property>
<property name="testOnBorrow" value="true"/>
</bean>
<!--
当该属性为true时,在调用borrowObject方法返回连接前,会调用validated方法进行校验。若校验失败,连接会从连接池中移除并销毁。同时会尝试重新借一个新的连接对象。
-->
<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg name="poolConfig" ref="jedisPoolConfig" />
<!--主机地址-->
<constructor-arg name="host" value="127.0.0.1" />
<!--端口号-->
<constructor-arg name="port" value="6379" type="int" />
<!--超时时间-->
<constructor-arg name="timeout" value="30000" type="int" />
</bean>
</beans>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
推荐阅读