U
U
Untiwe2021-03-07 18:37:03
Django
Untiwe, 2021-03-07 18:37:03

Why doesn't memcached save the cache?

Learn caching.
Installed memcached
pip install python-memcached

Enabled caching

CACHES  =  { 
    'default' :  { 
        'BACKEND' :  'django.core.cache.backends.memcached.MemcachedCache' , 
        'LOCATION' :  '127.0.0.1:11211' , 
    } 
}


I connected my context_processors because in the future I want to display information in the template

from django.core.cache import cache
def user_sitebar(request):
    cache.set('my_key', 'hello, world!', 30)
    print(cache.get('my_key'))


The output is always None. There are no errors, but for some reason the value is not read or set. Why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question