【发布时间】:2013-05-23 14:42:17
【问题描述】:
这里发生了什么?
当我用负值初始化缓存键时,我不能使用 incr 和 decr。 Get 按预期工作。
>>> from django.core.cache import cache
>>> cache.set('qwerty',-2)
>>> cache.incr('qwerty')
*** ValueError: Key ':1:qwerty' not found
如果我使用正数,我会得到预期的行为
>>> cache.set('qwerty',2)
>>> cache.incr('qwerty')
>>> cache.get('qwerty')
3
【问题讨论】:
-
注意,设置缓存后端为本地内存(django.core.cache.backends.locmem.LocMemCache)也能解决问题。
标签: django memcached python-2.6