使用 StrictRedisCluster 连接redis 集群
代码如下
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()
|
文章作者:阿文
版权声明:本博客所有文章除特别声明外,均采用
CC BY-NC-SA 4.0 许可协议。转载请注明来自
阿文的博客!