My cache settings:
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://127.0.0.1:6379/1',
'OPTIONS': {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
},
}
}
the host is 127.0.0.1, the port is 6379 and database is 1.
I want to add the data by using redis_connection
like this:
from django_redis import get_redis_connection
redis_conn = get_redis_connection('default')
redis_conn.set('somekey', 'somevalue')
So the redis database has the data now, I can get it by:
redis_conn.get('somekey')
but I couldn't get it by django.core.cache.cache
, although data exists in the database:
from django.core.cache import cache
cache.get('somekey') #return None
If I must use conn to set data and use cache to get data, what should I do?