Python 官方文档:入门教程 => 点击学习
环境:python 3.7.4Redis集群 单集群(无slave) 很多文章都说redis密码,今天验证的了很多次失败,查了相关资料有才知道连接方式,一下为代码,修改123456为自己代码就可以使用了 from rediscluste
环境:
python 3.7.4
Redis集群 单集群(无slave)
很多文章都说redis密码,今天验证的了很多次失败,查了相关资料有才知道连接方式,一下为代码,修改123456为自己代码就可以使用了
from rediscluster import StrictRedisCluster
list = [
'02200000001',
'02200000002',
'02200000003',
'02200000004',
'02200000005',
'02200000006',
'02200000007',
'02200000008',
'02200000009',
'02200000010'
]
def redis_cluster():
redis_nodes = [
{'host':'192.168.0.56','port':7001},
{'host':'192.168.0.56','port':7002},
{'host':'192.168.0.56','port':7003},
]
# print(redis_nodes[1])
try:
redisconn = StrictRedisCluster(startup_nodes=redis_nodes,passWord='123456')
print(redisconn)
# redisconn.set('yyy','tttt')
# A=redisconn.set('yyy')
# print(A)
except:
print('error')
for i in range(0,len(list)):
redisconn.set('user_phone_'+list[i],'111111')
print(redisconn.get('user_phone_'+list[i]))
redis_cluster()
--结束END--
本文标题: Python3 redis集群连接 (
本文链接: https://www.lsjlt.com/news/192542.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0