python访问redis

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

python访问redis

1 Linux上安装redis

a) 下载:

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. $ wget http://download.redis.io/releases/redis-3.0.5.tar.gz  

b) 编译:
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. # yum install gcc tcl  
  2. # tar -zxf redis-3.0.5.tar.gz  
  3. # cd redis-3.0.5  
  4. # make  
  5. # make test  
  6. # sudo make install  

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

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

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. $ redis-server  

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. $ 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 ? 在CODE上查看代码片 派生到我的代码片
  1. $ git clone https://github.com/andymccurdy/redis-py.git  

b) 安装:

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. $ cd redis-py  
  2. $ 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 ? 在CODE上查看代码片 派生到我的代码片
  1. $ git clone https://github.com/redis/hiredis.git  
  2. $ cd hiredis  
  3. $ make  
  4. $ 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 ? 在CODE上查看代码片 派生到我的代码片
  1. $ wget https://pypi.python.org/packages/source/h/hiredis/hiredis-0.2.0.tar.gz  

b) 安装:
[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. $ tar zxf hiredis-0.2.0.tar.gz  
  2. $ cd hiredis-0.2.0  
  3. $ python setup.py build  
  4. $ sudo python setup.py install  

5 python操作redis

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

http://blog.csdn.net/chenggong2dm/article/details/6102540


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值