python操作redis--pipeline

如何使用pipeline:

from redis.client import Redis

conn = Redis(host="0.0.0.0",port=6379,db=0,password="")

with conn.pipeline() as p:
    for i in range(100):
        p.set(f'key_{i}',i)
    p.execute()
print(conn.get("key_1"))

 

posted @ 2023-06-08 13:04  99号的格调  阅读(106)  评论(0编辑  收藏  举报