from rediscluster import StrictRedisCluster
startup_nodes = [{"host": "10.24.6.7", "port": "6379"}]
rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True)
print rc.set("bbbbbbbbbbbbbbbb", "bar")
True
print rc.get("bbbbbbbbbbbbbbbb")
from redis.sentinel import Sentinel
from redisclusterimport StrictRedisCluster
sentinel = Sentinel([('10.24.6.7', 26379)], socket_timeout=0.1)
ip, port = sentinel.discover_master('10.24.6.5master')
rc = StrictRedisCluster(host=ip, port=port, decode_responses=True)
print rc.set("bbbbbbbbbbbbbbbb", "bar")
print rc.get("bbbbbbbbbbbbbbbb")
下面关于Redis的文章您也可能喜欢,不妨参考下:
Ubuntu 14.04下Redis安装及简单测试
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
CentOS 6.3安装Redis