我尝试用我的 django 网站安装 johnny 缓存。
所以我设置了所有与约翰尼缓存相关的设置,如下所示:
CACHES = {
'default': {
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
'BACKEND': 'johnny.backends.memcached.MemcachedCache',
'JOHNNY_CACHE': True,
}
}
到目前为止,整个项目仍然在生产模式下正常运行。但是在设置中间件后立即出现
'johnny.middleware.LocalStoreClearMiddleware'
以下'johnny.middleware.QueryCacheMiddleware'
异常:
Environment:
Request Method: GET
Django Version: 1.3.1
Python Version: 2.6.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'core_knowledge_platform.core_web_service',
'south']
Installed Middleware:
('johnny.middleware.LocalStoreClearMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'johnny.middleware.QueryCacheMiddleware')
Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
117. response = middleware_method(request, e)
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/u1/msc/vg55/public_html/core_knowledge_web_platform/core_knowledge_platform/core_web_service/views.py" in __call__
95. return getattr(self, method)(request, *args, **kwargs)
File "/u1/msc/vg55/public_html/core_knowledge_web_platform/core_knowledge_platform/core_web_service/views.py" in GET
673. if not access.validate_user_is_editor(request.user):
File "/u1/msc/vg55/public_html/core_knowledge_web_platform/core_knowledge_platform/core_web_service/business_logic/access.py" in validate_user_is_editor
38. if papergroups:
File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in __nonzero__
113. iter(self).next()
File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in _result_iter
107. self._fill_cache()
File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in _fill_cache
772. self._result_cache.append(self._iter.next())
File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in iterator
273. for row in compiler.results_iter():
File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py" in results_iter
698. row = self.resolve_columns(row, fields)
File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/compiler.py" in resolve_columns
12. return row[:index_extra_select] + tuple(values)
Exception Type: TypeError at /publication/
Exception Value: cannot concatenate 'str' and 'tuple' objects
注意:约翰尼缓存没有在 INSTALLED_APPS 中设置,因为文档说它没用
编辑:
好吧,我发现只有在缓存命中时才会引发异常。当我等待 memcached 中的存储值过期时,然后在加载页面上,没有抛出异常......
为了给我的问题添加更多阴影,当我在 localhost 中激活 johnny 运行整个项目时,一切正常。但是当我在 prod 环境(Apache/2.2.15(CentOS))中运行它时,会抛出异常......并且两个环境上的 django 版本完全相同:1.3.1
注意:我已经设置了 okm 指定的中间件顺序
谢谢