无法在Heroku上配置MemCached

时间:2014-03-31 14:26:28

标签: django heroku memcached

我正在尝试使用heroku附加组件配置MemCached' MemCacheCloud'为我的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')
            }
      }
}

当我评论cache.set& dataaccess.py中的cache.get行,代码完美无缺。

1 个答案:

答案 0 :(得分:1)

感谢@ChrisWesseling提出的建议。

根据来自支持的通信,issue#25针对上述问题打开了。现在它已被修复,并且根据它们,pip存储库也会使用修复程序进行更新。