【发布时间】:2011-12-19 08:45:27
【问题描述】:
我正在尝试使用低级缓存 API 缓存 request.POST dict,但它似乎无法正常工作。我得到的不是缓存的字典,而是None 值。
这是我尝试过的:
print cache.get('forms_data') # It is None
education_formset = Education(
request.POST or cache.get('forms_data') or None, prefix='education')
if education_formset.is_valid():
if 'view' in request.POST:
cache.set('forms_data', request.POST, 600)
设置:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': 'unix:/tmp/memcached.sock',
}
}
运行代码时没有异常。
会不会是设置有问题,或者unix memcached.sock有问题?
【问题讨论】:
-
您的交互模式示例是正确的,
cache.set不返回任何内容 (None)。在交互模式下尝试cache.get。 -
谢谢,它的作品。我正在删除问题的错误方面。
标签: django django-settings django-cache