Answer the question
In order to leave comments, you need to log in
Why doesn't memcached return values when running workers?
Short description: in django shell memcached returns values, but not in workers.
Detailed:
memcached and celery settings:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_IGNORE_RESULT = True
CELERY_RESULT_BACKEND = 'cache+memcached://127.0.0.1:11211/'
comp_article = cache.get(url.strip())
if not comp_article:
print('set cache')
comp_article = NewArticle(url=url.strip(), compare=True)
array = comp_article.img_array
title = comp_article.url_title
lang = comp_article.language
val = CacheArticle(array, title, lang)
#CacheArticle = namedtuple('CacheArticle', ['img_array', 'url_title', 'language'])
cache.set(url, val, 86400)
sudo service memcached start
celery -A anf_man beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
celery -A anf_man worker --concurrency=1 -l info
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question