區分Python的redis客戶端:hiredis、hiredis-py、redis-py

因爲學習《Redis實戰》用的是Python,須要按Python的redis客戶端庫。被幾個庫搞得有點暈,在此區分一下。git

區分hiredis、hiredis-py、redis-py

redis官網Github:https://github.com/redis,這裏會看到兩個項目:github

  1. hiredis --> 是一個C語言的redis客戶端庫
  2. hiredis-py --> 是Python語言包裝了hiredis的redis客戶端庫

Andy McCurd的Github:https://github.com/andymccurdy,這裏會看到一個項目:redis

  1. redis-py --> 是一個Python語言的redis客戶端庫

所以,hiredis-pyredis-py都是Python語言的庫,二者沒有直接關係。
安裝方法:服務器

安裝hiredis-py: pip install hiredis
安裝redis-py: pip install rediside

Python文件中引入方法:性能

redis-py和hiredis-py的聯繫

redis-py文檔 中能夠看到這麼一段內容:學習

Parser classes provide a way to control how responses from the Redis server are parsed. redis-py ships with two parser classes, the PythonParser and the HiredisParser. By default, redis-py will attempt to use the HiredisParser if you have the hiredis module installed and will fallback to the PythonParser otherwise.ui

譯:Parser類能夠控制如何解析Redis服務器端響應的內容。redis-py提供兩個parser類,PythonParser和HiredisParser。若是你已經安裝了hiredis模塊,redis-py默認會嘗試使用HiredisParser,不然會使用PythonParser。code

Hiredis is a C library maintained by the core Redis team. Pieter Noordhuis was kind enough to create Python bindings. Using Hiredis can provide up to a 10x speed improvement in parsing responses from the Redis server. The performance increase is most noticeable when retrieving many pieces of data, such as from LRANGE or SMEMBERS operations.orm

譯:Hiredis是一個C語言的庫,是由Redis核心團隊維護的。Pieter Noordhuis還寫了一個Python版本的Hiredis(即hireids-py)。使用Hiredis能夠使得redis客戶端解析服務端響應內容的速度提高10倍。並且當執行檢索多條數據時性能更顯著,如LRANGESMEMBERS等。

Hiredis is available on PyPI, and can be installed via pip or easy_install just like redis-py.

譯:Hiredis能夠在PyPI上找到,你能夠使用easy_install或pip來安裝(hiredis-py)。

$ pip install hiredis
or
$ easy_install hiredis

所以,安裝redis-py同時安裝hiredis-py,使用redis-py的時候會提高性能

相關文章
相關標籤/搜索