您的位置:首页 > 数据库 > Redis

python访问redis

2016-02-02 18:31 597 查看
转载自:http://blog.csdn.net/ubuntu64fan/article/details/50624293


python访问redis


1 Linux上安装redis

a) 下载:

[html] view
plain copy

 print?





$ wget http://download.redis.io/releases/redis-3.0.5.tar.gz  

b) 编译:

[html] view
plain copy

 print?





# yum install gcc tcl  

# tar -zxf redis-3.0.5.tar.gz  

# cd redis-3.0.5  

# make  

# make test  

# sudo make install  

这样可执行文件redis-server等就从redis-3.0.5/src拷贝到/usr/local/bin

c) 启动服务(6379端口要打开)

[html] view
plain copy

 print?





$ redis-server  



[html] view
plain copy

 print?





$ redis-server /path/to/redis.conf  

参考下面的redis.conf的配置项: redis配置详解

http://blog.csdn.net/ithomer/article/details/9232891


2 redis-py

redis-py 这是 Redis 目前最成熟的 Python 客户端开发包。

redis 主页:

https://github.com/andymccurdy/redis-py

a) 下载源码:

[html] view
plain copy

 print?





$ git clone https://github.com/andymccurdy/redis-py.git  

b) 安装:

[html] view
plain copy

 print?





$ cd redis-py  

$ sudo python redis install  


3 hiredis

hiredis是redis数据库的C接口,目前只能在linux下使用,几个基本的函数就可以操作redis数据库了。hiredis 是 Redis 官方指定的 C 语言客户端开发包,支持 Redis 完整的命令集、管线以及事件驱动编程。
hiredis主页:

https://github.com/redis/hiredis

a) 下载安装:

[html] view
plain copy

 print?





$ git clone https://github.com/redis/hiredis.git  

$ cd hiredis  

$ make  

$ sudo make install  

例子:

http://blog.csdn.net/mfc_vc_andy/article/details/8095839

http://www.leoox.com/?p=304


4 hiredis-py

python对hiredis的包装类。

主页:

https://github.com/redis/hiredis-py
a) 下载:

[html] view
plain copy

 print?





$ wget https://pypi.python.org/packages/source/h/hiredis/hiredis-0.2.0.tar.gz  

b) 安装:

[html] view
plain copy

 print?





$ tar zxf hiredis-0.2.0.tar.gz  

$ cd hiredis-0.2.0  

$ python setup.py build  

$ sudo python setup.py install  


5 python操作redis

http://blog.csdn.net/chosen0ne/article/details/7319807

http://blog.csdn.net/chenggong2dm/article/details/6102540
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: