************************************【单机环境redis客户端配置】***********************************************
Jedis是redis的Java客服端实现。对外调用的类只需要了解Jedis,JedisPool,JedisPoolConfig,JedisSharedInfo,SharedJedisPool,SharedJedis即可满足基本需求,其中带有shared的类是实现分片连接池的类,适用于redis集群。
下面通过spring的容器整合redis,通过spring的整合更能够简洁灵活的配置redis。
1、spring要管理的两个类:jedisPoolConfig(连接池配置)、jedisPool(连接池)
(1)redisTest.xml配置文件:<?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-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- spring只允许有一个<context:property-placeholder/>-->
<!--如果你有多个数据源需要通过<context:property-placeholder管理,且不愿意放在一个配置文件里,那么一定要加上ignore-unresolvable=“true"-->
<context:property-placeholder location="classpath:/com/redisLock/redis-conf.properties,classpath:/com/redisLock/redis-password.properties"
ignore-unresolvable="true"/>
<context:annotation-config/>
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="${jedisPool.maxTotal}"></property>
<property name="maxIdle" value="${jedisPool.maxIdle}"></property>
<property name="minIdle" value="${jedisPool.minIdle}"></property&g