国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python連接Redis的基本配置方法

2020-02-15 22:57:37
字體:
來源:轉載
供稿:網友

在Linux系統下Python連接Redis的基本配置方法具體操作步驟

系統環境:

OS:Oracle Linux Enterprise 5.6

Redis:redis-2.6.8

Python:Python-2.7.3

redis的python包版本:redis-2.7.2.tar

前提條件:

1.確保Redis已成功安裝并且正確配置,參考文檔

主從配置文檔:

//www.jb51.net/article/147397.htm

2.確保Python環境已成功配置,參考文檔

https://www.jb51.net/article/109765.htm

配置python連接redis:

1.安裝Redis的Python包:

使用easy-install安裝,關于easy-install的配置,參考以上Python環境的搭建。

[root@njdyw bin]# easy_install2.7.3 redisSearching for redisReading http://pypi.python.org/simple/redis/Reading http://github.com/andymccurdy/redis-pyBest match: redis 2.7.2Downloading http://pypi.python.org/packages/source/r/redis/redis-2.7.2.tar.gz#md5=17ac60dcf13eb33f82cc25974ab17157Processing redis-2.7.2.tar.gzRunning redis-2.7.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8FAlft/redis-2.7.2/egg-dist-tmp-JzQViJzip_safe flag not set; analyzing archive contents...Adding redis 2.7.2 to easy-install.pth file Installed /usr/local/python2.7.3/lib/python2.7/site-packages/redis-2.7.2-py2.7.eggProcessing dependencies for redisFinished processing dependencies for redis

安裝Parser包(可選)

說明:Parser可以控制如何解析redis響應的內容。redis-py包含兩個Parser類,PythonParser和HiredisParser。默認,如果已經安裝了hiredis模塊,redis-py會使用HiredisParser,否則會使用PythonParser。

HiredisParser是C編寫的,由redis核心團隊維護,性能要比PythonParser提高10倍以上,所以推薦使用。安裝方法,使用easy_install:

[root@njdyw ~]# easy_install2.7.3 hiredisSearching for hiredisReading http://pypi.python.org/simple/hiredis/Reading https://github.com/pietern/hiredis-pyBest match: hiredis 0.1.1Downloading http://pypi.python.org/packages/source/h/hiredis/hiredis-0.1.1.tar.gz#md5=92128474f6fb027cfb8587fce724ea8eProcessing hiredis-0.1.1.tar.gzRunning hiredis-0.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZanSCB/hiredis-0.1.1/egg-dist-tmp-XCZBQ0zip_safe flag not set; analyzing archive contents...Adding hiredis 0.1.1 to easy-install.pth file Installed /usr/local/python2.7.3/lib/python2.7/site-packages/hiredis-0.1.1-py2.7-linux-x86_64.eggProcessing dependencies for hiredisFinished processing dependencies for hiredis

2.檢查安裝是否成功

--easy-install安裝的擴展包默認在python的site-packages目錄下

[root@njdyw ~]#whereis python2.7.3python2.7: /bin/python2.7.3 /usr/local/python2.7.3[root@njdyw ~]#cd /usr/local/python2.7.3/lib/python2.7/site-packages/[root@njdyw site-packages]# ll

總計 408

-rw-r--r-- 1 root root  239 03-21 10:45 easy-install.pth-rw-r--r-- 1 root root  119 03-21 10:07 README-rw-r--r-- 1 root root 60401 03-21 10:45redis-2.7.2-py2.7.egg-rw-r--r-- 1 root root 332125 03-21 10:12 setuptools-0.6c11-py2.7.egg-rw-r--r-- 1 root root   30 03-21 10:12 setuptools.pth            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灯塔市| 庄浪县| 谢通门县| 临颍县| 双城市| 红安县| 丰宁| 阿荣旗| 玉林市| 德格县| 青阳县| 孙吴县| 武邑县| 南皮县| 碌曲县| 灵台县| 长岭县| 曲水县| 梧州市| 河西区| 铁岭县| 睢宁县| 华安县| 祁东县| 棋牌| 柏乡县| 浮梁县| 都江堰市| 阳新县| 嘉定区| 循化| 象州县| 桂平市| 五寨县| 南澳县| 家居| 家居| 普兰县| 涟源市| 赤壁市| 高阳县|