share-image
ESC

redis 连接集群

使用 StrictRedisCluster 连接redis 集群

代码如下

# !/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()

文章作者:阿文
文章链接: https://www.awen.me/post/34408.html
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿文的博客
本文于 2019-02-27 发布,已超过半年(2528天),请注意甄别内容是否已过期。