Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this relevant with Django 4.0? #585

Open
aqeelat opened this issue Dec 28, 2021 · 6 comments
Open

Is this relevant with Django 4.0? #585

aqeelat opened this issue Dec 28, 2021 · 6 comments
Labels

Comments

@aqeelat
Copy link
Member

aqeelat commented Dec 28, 2021

Since Django 4.0 has native redis support, do we still need to use this library?

@WisdomPill
Copy link
Member

WisdomPill commented Dec 28, 2021

DISCLAIMER I am biased, since I am a user and a maintainer of django-redis.

Yes, but the native support of django 4 is very basic,
if you need a compressor, serializer, connection pool or sentinel support you can not do that with django native support,
in some cases it would be very difficult (sentinel and compressor),
in other not so much (serializers).

Furthermore, if you need more control over how the keys are stored,
like expire_at and millisecond precision you could only do it with django-redis.
Locks are also something nice that in my day job makes a difference,
for syncing celery tasks for example,
django-redis can help you create distributed redis locks while django native support could not.
Another thing, for performance, is that django does not supports hiredis while django-redis does.
Also, in this case I do not really know, I would be glad to be corrected,
django natively does not support options for the connection pool.
For certificates also django does not support them.

django-redis is highly configurable, you can easily define different clients, or use sharded client for that manner.

Have a look here

But, if you need very basic caching,
then using django-redis or django native support should not make any difference.
Maybe in the future django will do the same things as django-redis.

In short, django-redis is more redis specific, while django native support is more basic.

@WisdomPill WisdomPill pinned this issue Dec 28, 2021
@saranglakare
Copy link

I feel you should integrate with django. There's no point in having extra package for such a core functionality. At the same time, I agree with you that django-redis is for those who have fixated on using redis for their cache.

@FlipperPA
Copy link

FlipperPA commented May 11, 2022

It would be awesome to see some of these features make it upstream into Django core.

@getup8
Copy link

getup8 commented May 27, 2022

FWIW it does look like Django supports hiredis and potentially connection pools?

From lower down the page at https://docs.djangoproject.com/en/4.0/topics/cache/#redis-1 :

Here’s an example configuration for a redis based backend that selects database 10 (by default Redis ships with 16 logical databases), specifies a parser class (redis.connection.HiredisParser will be used by default if the hiredis-py package is installed), and sets a custom connection pool class (redis.ConnectionPool is used by default)

@alexandernst
Copy link

We're at Django 5.x now, how much of this comparison / reasons to use django-redis are still valid?

@WisdomPill
Copy link
Member

now it's even more diverged than before, because we support sentinel and more commands for different data structures such as hashmaps and sets. Future developments are going to add more support for specifics of redis, as with memcached as well, if you want or need a more advanced use case, you have to go outside of plain basic django

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants