Python Django Memcache:比较并设置
在Django中进行比较和设置,如下所示Python Django Memcache:比较并设置,python,django,caching,memcached,Python,Django,Caching,Memcached,在Django中进行比较和设置,如下所示 You can access the memcached client via django though: >>> from django.core import cache >>> c=cache.get_cache('default') >>> help(c._client.cas) 但不知怎么的,我无法让它工作 >>> from django.core import
You can access the memcached client via django though:
>>> from django.core import cache
>>> c=cache.get_cache('default')
>>> help(c._client.cas)
但不知怎么的,我无法让它工作
>>> from django.core import cache
>>> c=cache.get_cache('memcache')
>>> help(c._client.cas)
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'MemcachedCache' object has no attribute '_client'
来自django.core导入缓存的>>
>>>c=缓存。获取缓存('memcache'))
>>>帮助(c._client.cas)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
AttributeError:'MemcachedCache'对象没有属性'\u client'
如果不是上面所示的方法,我如何在Django中进行比较和设置
看了源代码后,我使用了Django 1.3版。!我在BaseMachedCache中找到了以下内容:
@property
def _cache(self):
"""
Implements transparent thread-safe access to a memcached client.
"""
if getattr(self, '_client', None) is None:
self._client = self._lib.Client(self._servers)
return self._client
因此,我想说,这将起作用:
c._cache.cas
试试看,让我知道
有关详细信息: