1.Maven导包
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
2.Spring配置文件加入节点IP
redis:
nodes:
- 192.168.2.210:7000
- 192.168.2.210:7001
- 192.168.2.210:7002
- 192.168.2.210:7003
- 192.168.2.210:7004
- 192.168.2.210:70053.注入依赖@Autowiredprivate JedisCluster redis;4.常用方法举例
添加键值对
set(final String key, final String value)设置失效时间expire(final String key, final int seconds)获取键值对get(final String key)