python访问redis

1337035223 8年前

来自: http://blog.csdn.net/ubuntu64fan/article/details/50624293


python访问redis

1 Linux上安装redis

a) 下载:

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

b) 编译:
# 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端口要打开)

$ redis-server

$ 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) 下载源码:

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

b) 安装:

$ 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) 下载安装:

$ 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) 下载:
$ wget https://pypi.python.org/packages/source/h/hiredis/hiredis-0.2.0.tar.gz

b) 安装:
$ 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