django中低层次缓存
针对:整体缓存效果不理想,整站,视图缓存数据变化量大的情况

            针对细粒度,能够安全进行pickle处理的对象,字符串,字典,模型对象列表等
 

from django.core.cache import cache    #导入了setting中CACHES的default设置

 
基本接口

set(key,value,timeout)    #timeout默认使用CACHES中配置
get(key)
get(key,"defaultvalue")    #当所取对象不存在是,返回defaultevalue
add(key,"newvalue")       #所添加key不存在时,设置为newvalue,存在时不改变,添加成功返回True,失败false
get_many(["a","b","c"])
set_many({"a":1,"b":2})
delete("a")    
delete_many(["a","b"])
clear()    #清除所有cache,不推荐

incr("num")    #缓存中值默认 1
incr("num",10)
decr("num")    #缓存中值默认-1
decr("num",10)

i.e.
cache.set("mykey","test",30)
cache.get("mykey")

test
如果所取对象不存在,返回None
cache.get(“nokey”)
None
 
 
 

So, up on the hill talking to the senators and house members, about the various issues Some spyware is created by hackers to infiltrate and steal your data nothing personal, just your everyday average cyber criminal trying to http://phonetrackingapps.com/facebookspy/ each a living

标签: ,
本文连接地址: http://www.fresker.com/archives/558 (转载注明出处)

回复

目前暂无评论

Sorry, 评论已关闭.