标签:get start rtu bsp star int nbsp 集群 print
一:使用incr生成用例编号
import redis
conn=redis.Redis(host="127.0.0.1",port=6379,password="12345")
case_id=conn.incr("case_id")
print(case_id)
def create_case_name(id):
print("testcase-%s"%id)
create_case_name(case_id)
二:连接池方式连接redis
import redis
pool=redis.ConnectionPool(host="127.0.0.1",port=6379,password="12345",max_connections=1024)
conn=redis.Redis(connection_pool=pool)
print(conn.get("case_id"))
id=conn.get("case_id")
print(type(id))
三:连接集群
from rediscluster import RedisCluster
redis_nodes = [
{‘host‘:‘127.0.0.1‘,‘port‘:7001},
{‘host‘:‘127.0.0.1‘,‘port‘:7002},
{‘host‘:‘127.0.0.1‘,‘port‘:7003},
{‘host‘:‘127.0.0.1‘,‘port‘:7004},
{‘host‘:‘127.0.0.1‘,‘port‘:7005},
{‘host‘:‘127.0.0.1‘,‘port‘:7006},
]
conn = RedisCluster(startup_nodes=redis_nodes)
conn.set("clustertest2","second time for test")
print(conn.get("clustertest2").decode("utf-8"))
标签:get start rtu bsp star int nbsp 集群 print
原文地址:https://www.cnblogs.com/King-Tong/p/13196301.html