我正在使用 django 1.7 和 python3.4。我最近安装了 Memcached,并试图根据站点缓存将它与 python-memcached 一起使用。但是,一旦我在 settings.py 中定义了默认缓存后端,我的应用程序就会停止工作并抛出此错误:
'str' does not support the buffer interface
安装的中间件和回溯是:
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware')
Traceback:
File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
87. response = middleware_method(request)
File "C:\Python34\lib\site-packages\django\middleware\cache.py" in process_request
148. cache_key = get_cache_key(request, self.key_prefix, 'GET', cache=self.cache)
File "C:\Python34\lib\site-packages\django\utils\cache.py" in get_cache_key
223. headerlist = cache.get(cache_key, None)
File "C:\Python34\lib\site-packages\django\core\cache\backends\memcached.py" in get
82. val = self._cache.get(key)
File "C:\Python34\lib\site-packages\memcache.py" in get
1002. return self._get('get', key)
File "C:\Python34\lib\site-packages\memcache.py" in _get
986. return _unsafe_get()
File "C:\Python34\lib\site-packages\memcache.py" in _unsafe_get
957. server.send_cmd("%s %s" % (cmd, key))
File "C:\Python34\lib\site-packages\memcache.py" in send_cmd
1299. self.socket.sendall(cmd + '\r\n')
Exception Type: TypeError at /ask/
Exception Value: 'str' does not support the buffer interface
请告诉我什么是问题和解决方案。python-memcache 绑定是否不适用于 python3.4