Using multiple caches on the same db
VaZark opened this issue · 1 comments
VaZark commented
How does cache clearing work when used with django-redis ? Does all the data associated with the store get cleared or is the lib capable of removing only the keys created by it?
For example,
CACHES = {
# Per-tenant caching using key-function
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://{REDIS_URL}/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"TIMEOUT": 60 * 15,
},
},
"session-cache": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": f"redis://{REDIS_URL}/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
"TIMEOUT": 60 * 60 * 6,
},
},
}
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "session-cache"
Does session-cache
get cleared since it is on the same store as default
?
WisdomPill commented
hey @VaZark sorry for the late reply.
the lib just fills TTL in redis, then redis by itself will clear the item out of the db.
So keys created with default
will be deleted (expire) after 15 minutes while the ones created with session-cache
will be deleted (expire) after 6 hours, regardless of in which redis db they reside.
Hope this helps