python 中使用memcache

非常简单,首先是在本机安装memcache服务并启动,

d:\memcached\memcached.exe -d install  #安装

d:\memcached\memcached.exe -d start    #启动

如果没有在启动时配置参数,默认端口则为11211

接着下载 memcache python版client

#coding=utf8

import memcache

mcache= memcache.Client(['127.0.0.1:11211'])
print mcache.set('say','hello,memcache') #display - True
value = mcache.get('say')
print value #display - hello,memcache

更详细文档在这里

https://developers.google.com/appengine/docs/python/memcache/

附上启动参数说明:

-d 选项是启动一个守护进程

-m 是分配给Memcache使用的内存数量,单位是MB,默认64MB

-M return error on memory exhausted (rather than removing items)

-u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户

-l 是监听的服务器IP地址,默认为所有网卡

-p 是设置Memcache的TCP监听的端口,最好是1024以上的端口

-c 选项是最大运行的并发连接数,默认是1024

-P 是设置保存Memcache的pid文件

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值