Redis 5.0.0集群 ImportError:cannot import name StrictRedisCluster

连接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'))

 

你可能感兴趣的:(redis,Python)