redis.properties:
session.time.out=900
#redis.ip=127.0.0.1
#redis.port=6379
# Redis settings
#sentinel1\u7684IP\u548C\u7AEF\u53E3
im.hs.server.redis.sentinel1.host=192.168.13.62
im.hs.server.redis.sentinel1.port=26382
#sentinel2\u7684IP\u548C\u7AEF\u53E3
im.hs.server.redis.sentinel2.host=192.168.13.63
im.hs.server.redis.sentinel2.port=26382
#sentinel\u7684\u9274\u6743\u5BC6\u7801
im.hs.server.redis.sentinel.masterName=redis-sentinel(要和sentinel中的名字一样)
#im.hs.server.redis.sentinel.password=hezhixiong
#\u6700\u5927\u95F2\u7F6E\u8FDE\u63A5\u6570
im.hs.server.redis.maxIdle=500
#\u6700\u5927\u8FDE\u63A5\u6570\uFF0C\u8D85\u8FC7\u6B64\u8FDE\u63A5\u65F6\u64CD\u4F5Credis\u4F1A\u62A5\u9519
im.hs.server.redis.maxTotal=5000
im.hs.server.redis.maxWaitTime=1000
im.hs.server.redis.testOnBorrow=true
#\u6700\u5C0F\u95F2\u7F6E\u8FDE\u63A5\u6570\uFF0Cspring\u542F\u52A8\u7684\u65F6\u5019\u81EA\u52A8\u5EFA\u7ACB\u8BE5\u6570\u76EE\u7684\u8FDE\u63A5\u4F9B\u5E94\u7528\u7A0B\u5E8F\u4F7F\u7528\uFF0C\u4E0D\u591F\u7684\u65F6\u5019\u4F1A\u7533\u8BF7\u3002
im.hs.server.redis.minIdle=300
spring-redis.xml:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="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 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> class="org.springframework.data.redis.connection.RedisSentinelConfiguration"> value="${im.hs.server.redis.sentinel1.host}"> value="${im.hs.server.redis.sentinel1.port}"> value="${im.hs.server.redis.sentinel2.host}"> value="${im.hs.server.redis.sentinel2.port}"> class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:password="abcd_123456"> //集群的时候这里要用密码才能连接,之后正常使用
java代码:
@Autowired(required=false)
private RedisTemplateDelegate
public RedisTemplateDelegate
return redisService;
}
public void setRedisService(RedisTemplateDelegate
this.redisService = redisService;
}
//Map
//Map
//ma.put("11", 22);
//redisService.set("kk", ma);
//maq=redisService.get("kk");
//maq.get("11");
当然如果不用spring集成的话java写法不一样,需要代码中写密码
参看:
http://www.cnblogs.com/qlong8807/p/5893422.html