首页 > 编程语言 > 详细

Python memcache和redis

时间:2016-09-05 01:40:49      阅读:349      评论:0      收藏:0      [点我收藏+]

1.memcache的安装

http://www.cnblogs.com/zgx/archive/2011/08/10/2134097.html

memcached -d -m 10    -u root -l 192.168.15.128 -p 12000 -c 256 -P /tmp/memcached.pid

参数说明:
    -d 是启动一个守护进程
    -m 是分配给Memcache使用的内存数量,单位是MB
    -u 是运行Memcache的用户
    -l 是监听的服务器IP地址
    -p 是设置Memcache监听的端口,最好是1024以上的端口
    -c 选项是最大运行的并发连接数,默认是1024,按照你服务器的负载量来设定
    -P 是设置保存Memcache的pid文件

2.在memcache模块中执行程序报错

a bytes-like object is required, not ‘str‘ - error

原因是:

python-memchached is not supported on python 3.5 If you‘ve used python-memchached, The following commands will help you.

pip uninstall python-memcached
pip install python3-memcached

3.memcache的示例

import memcache

mc = memcache.Client([192.168.15.128:12000],debug=True)
mc.set("some_key", "Some value")
ret = mc.get("some_key")
print (ret)
结果:
Some value

4.memcache的一些方法

http://www.cnblogs.com/wupeiqi/articles/5132791.html

 

Python memcache和redis

原文:http://www.cnblogs.com/python-study/p/5840922.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!