Python3 redis cluster connection (with password authentication)

Environment:
Python 3.7.4
Redis cluster single cluster (non-slave)

Many articles say redis password, verify today's many failures, check the relevant information to know talented connection, look for the code, modify code 123456 for themselves can use

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()

Guess you like

Origin blog.51cto.com/3138583/2427276