Redis pipe lining in Python

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)

#Normal case
start = time.time()
for key in range(1000):
    r.get(key)
stop = time.time()
print stop - start

#When pipe lining
start = time.time()
with r.pipeline() as pipe:
    for key in range(1000):
        pipe.get(key)
    pipe.execute()
stop = time.time()
print stop - start

Execution result: % python test_pipline.py 0.168359994888 0.0300588607788

Recommended Posts

Redis pipe lining in Python
Implement Redis Mutex in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
Do something like Redis transactions in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
Try a functional programming pipe in Python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Redis Shortest Introduction (3) API in 5 minutes even in Python
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Key input in Python