8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PythonでRedisのパイプライニング

Posted at
test_pipline.py
# -*- 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

実行結果:
% python test_pipline.py
0.168359994888
0.0300588607788

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?