redis 连接集群

使用 StrictRedisCluster 连接redis 集群

代码如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# !/usr/bin/env python
# coding:utf-8

from rediscluster import StrictRedisCluster
import sys


def redis_cluster():
redis_nodes = [{'host': '192.168.10.164', 'port': 6380},
{'host': '192.168.10.241', 'port': 6380},
{'host': '192.168.10.165', 'port': 6380},
{'host': '192.168.10.250', 'port': 6380}
]
redisconn = StrictRedisCluster(startup_nodes=redis_nodes,skip_full_coverage_check=True)
redisconn.set('name','admin')
redisconn.set('age',18)
print("name is: ", redisconn.get('name'))
print("age is: ", redisconn.get('age'))



redis_cluster()
阿文 wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!