发布时间:2019-09-26 07:23:24编辑:auto阅读(1753)
环境:
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()
上一篇: python3 函数迭代器
下一篇: 4. python3 表达式if ...
47756
46264
37145
34652
29241
25899
24769
19873
19435
17928
5725°
6330°
5847°
5898°
7000°
5836°
5856°
6370°
6326°
7691°