python使用memcached做缓存,pythonmemcached,在python中使用me
python使用memcached做缓存,pythonmemcached,在python中使用me
在python中使用memcache,需要先安装memcached的python client,这里列出了很多,你可以选择一个来安装。
import memcachemc = memcache.Client(['192.168.0.1:11211'], debug=0)
写入缓存:
mc.set("key", "value")
第三个参数默认为0,也就是数据永不超时。
如果这样设置:mc.set("key", "value", 1)
表示一秒后超时
读取缓存
value = mc.get("key")print value
删除缓存
mc.delete("key")
自增和自减
mc.set("key", "1")mc.incr("key")mc.decr("key")
相关内容
- python使用SGMLParser提取文本正文内容,pythonsgmlparser,如下
- Python thread socket server,pythonsocket,从网上参考了一些代码
- python list使用技巧总结,pythonlist使用技巧,判断一个 l
- python dict使用技巧,pythondict,在 Dictionary
- Python统计列表中元素出现的次数,python统计列表元素
- Python yield使用示例,pythonyield示例,下面2段代码通过Py
- python使用eval,exec将字符串(string)转为字典(dict),pythone
- Python POP3 收取邮件,pythonpop3,python 为我们提供
- python爬虫抓网页的总结,python爬虫抓,学用python也有3个
- python核心模块之pickle和cPickle的使用示例,picklecpickle,
评论关闭