连接redis集群报一下错误:
ImportError: cannot import name 'StrictRedisCluster'
# -*- coding:utf-8 -*-
from rediscluster import StrictRedisCluster
nodes = [{"host": "localhost", "port": "7001"}]
r = StrictRedisCluster(startup_nodes=nodes, decode_responses=True)
r.set('test', 111)
print(r.get('test'))
解决:
redis5.0修改了方法不支持该StrictRedisCluster方法,使用RedisCluster方法.
# -*- coding:utf-8 -*-
from rediscluster import RedisCluster
nodes = [{"host": "localhost", "port": "7001"}]
r = RedisCluster(startup_nodes=nodes, decode_responses=True)
r.set('test', 111)
print(r.get('test'))