Open seaswalker opened 3 years ago
import redis import time from datetime import datetime pool = redis.ConnectionPool(host='127.0.0.1', port=6379, password=None, db=0, decode_responses=True) r = redis.Redis(connection_pool=pool) print("开始执行, 当前时间: %s." %datetime.now().strftime("%H:%M:%S")) start = time.time() i = 0 while i < 6000: with r.pipeline(transaction=False) as p: j=0 while j < 1000: r.hset("test_hash", str(300000000 + j + i * 1000), "10,32,3") j=j+1 p.execute() i = i+1 r.close() print("耗时: " + str(time.time() - start) + "毫秒.") print("done")