coderedcorp/wagtail-cache

Removal of django-redis compatibility

Closed this issue · 4 comments

I saw you removed the django-redis compatibility layer in the latest version -- we were using the DB option in django-redis to separate this cache from our other uses -- do you know if this is still possible with django.core.cache.backends.redis.RedisCache? It doesn't seem to be documented.

Django lets you define multiple separate caches. I'd recommend defining a cache just for wagtail-cache. Would that work?

https://docs.coderedcorp.com/wagtail-cache/getting_started/install.html#using-a-separate-cache-backend

https://docs.djangoproject.com/en/4.2/topics/cache/#cache-arguments

I'm not super familiar with redis, but if you're talking about specifying a DB, the Django docs link to the redis-py docs which allow you to specify a DB in the connection string when defining the cache. https://redis-py.readthedocs.io/en/stable/connections.html#redis.connection.ConnectionPool.from_url

@vsalvino the URL params could work for that, which was the main issue. The other drawbacks are we can't use other django-redis options that improve performance like compressor and parser_class.

Was there a reason to remove the django-redis compatibility?

The main reason for removal was the everyone who was using it (to our knowledge) had moved on since Django 4 added native redis support. It was actually more of a hack and didn't have any unit tests either. So it seemed unnecessary to try and maintain it.

I would say if you need it, add this code to your project, so that you can maintain it according to your needs:

https://github.com/coderedcorp/wagtail-cache/blob/release/1/wagtailcache/compat_backends/django_redis.py

Better yet, I'd encourage you to contribute to django-redis, to make their backend compatible with the built-in Django cache backends. Currently it is NOT compatible and behaves differently, which is why we had to add that hack.