gpt4 book ai didi

django - 无法在 Heroku 上配置 MemCached

转载 作者:行者123 更新时间:2023-12-04 22:08:14 25 4
gpt4 key购买 nike

我正在尝试使用 heroku 附加组件' MemCacheCloud 配置 MemCached ' 用于我的 Django 网站。当我运行试图获取/设置缓存的代码时,出现以下错误

Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response 
Mar 31 19:36:17 mycloudapp app/web.1: response = callback(request, *callback_args, **callback_kwargs)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.12.0.10/newrelic/hooks/framework_django.py", line 492, in wrapper
Mar 31 19:36:17 mycloudapp app/web.1: return wrapped(*args, **kwargs)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/jobs/views.py", line 53, in job_view
Mar 31 19:36:17 mycloudapp app/web.1: skill_list = get_all_skills()
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/common/dataaccess.py", line 13, in get_all_skills
Mar 31 19:36:17 mycloudapp app/web.1: cache.set(ALL_SKILLS, skill_list)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 71, in set
Mar 31 19:36:17 mycloudapp app/web.1: self._cache.set(key, value, self._get_memcache_timeout(timeout))
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.12.0.10/newrelic/api/memcache_trace.py", line 70, in __call__
Mar 31 19:36:17 mycloudapp app/web.1: return self._nr_next_object(*args, **kwargs)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/client.py", line 126, in set
Mar 31 19:36:17 mycloudapp app/web.1: returns.append(server.set(key, value, time))
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/protocol.py", line 372, in set
Mar 31 19:36:17 mycloudapp app/web.1: return self._set_add_replace('set', key, value, time)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/protocol.py", line 345, in _set_add_replace
Mar 31 19:36:17 mycloudapp app/web.1: time, key, value))
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/socket.py", line 224, in meth
Mar 31 19:36:17 mycloudapp app/web.1: return getattr(self._sock,name)(*args)
Mar 31 19:36:17 mycloudapp app/web.1: File "/app/.heroku/python/lib/python2.7/socket.py", line 170, in _dummy
Mar 31 19:36:17 mycloudapp app/web.1: raise error(EBADF, 'Bad file descriptor')
Mar 31 19:36:17 mycloudapp app/web.1: error: [Errno 9] Bad file descriptor

我在dataaccess.py中访问缓存的代码-

from django.core.cache import cache

ALL_SKILLS = "allskills"
def get_all_skills():
skill_list = cache.get(ALL_SKILLS)
if not skill_list:
skill_list = MySkillTable.objects.all()
cache.set(ALL_SKILLS, skill_list)
return skill_list

我的 settings.py 有一个条目

CACHES = {
'default': {
'BACKEND': 'django_bmemcached.memcached.BMemcached',
'LOCATION': get_env_setting('MEMCACHEDCLOUD_SERVERS').split(','),
'OPTIONS': {
'username': get_env_setting('MEMCACHEDCLOUD_USERNAME'),
'password': get_env_setting('MEMCACHEDCLOUD_PASSWORD')
}
}
}

当我评论 dataaccess.py 中的 cache.set 和 cache.get 行时,代码运行完美。

最佳答案

感谢@ChrisWesseling 的建议。

根据来自支持 issue#25 的沟通针对上述问题被打开。现在它已被修复,并且根据他们的要求,pip 存储库也已更新。

关于django - 无法在 Heroku 上配置 MemCached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22764218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com