r = redis.Redis()
p = r.pipeline()
p.set("transError", var)
p.execute()
測定プログラム
# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import unicode_literals import redis import time r = redis.StrictRedis(host='localhost', port=6379, db=0) # 通常の場合 start = time.time() for key in range(1000): r.get(key) stop = time.time() print stop - start # パイプライニングした場合 start = time.time() with r.pipeline() as pipe: for key in range(1000): pipe.get(key) pipe.execute() stop = time.time() print stop - start