我在我的缓存中设置了一个查询集:
cache.set('person',Lecture_Detail.objects.all())
在我看来:
from django.core.cahe import cache
t3=datetime.datetime.now()
list(Lecture_Detail.objects.all())
t5 = datetime.datetime.now()
print "time before",(t5 - t3)
g = cache.get('person')
t4 = datetime.datetime.now()
print "time after",(t4 - t5)
g = cache.get('person')
t6 = datetime.datetime.now()
print "time after",t6-t4
g = cache.get('person')
t7 = datetime.datetime.now()
print "time after",t7-t6
当我执行它时,它的输出是:
time before 0:00:00.014256
time after 0:00:01.366022
time after 0:00:01.552436
time after 0:00:01.433049
所以我认为我的 redis 与 django-redis 无关。我的设置是:
CACHES = {
"default": {
"BACKEND": "redis_cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379:1",
"OPTIONS": {
"CLIENT_CLASS": "redis_cache.client.DefaultClient",
}
}
}
所以请我给我一些建议.. 提前谢谢..