from rediscluster import RedisCluster
import redis
redis_nodes_c3 = [{'host': '***', 'port': '###'},
{'host': '22312312', 'port': '09090'}]
rc = RedisCluster(startup_nodes=redis_nodes_staging, decode_responses = True, max_connections=40,
)
rc.set("SEA_1","xxx",ex=10)
a = rc.get('SEA_1')
print(a)
一个简单的代码就是get set一个KeyValue,但是一共出现了两个问题:
问题1:
写完这个代码之后 开心的进行验证 发现出现了问题 报错:ImportError: cannot import name ‘RedisCluster’ 不能引入RedisCluster模块, why? 这里我写的好好的,也安装过了redis-py-cluster,为什么 引用不进来呢,原因是我的文件名称被我写成了redis.py 自己的文件名和模块名称重复了 把文件名称改一下就行了
问题2:
修改完文件名称后redis.exceptions.ResponseError: unknown command ‘CONFIG’
rc = RedisCluster(startup_nodes=redis_nodes_staging, decode_responses = True, max_connections=40,
skip_full_coverage_check = True)
增加skip_full_coverage_check为True设置,跳过链接集群时候的检查