jpadilla / django-rest-framework-jwt

JSON Web Token Authentication support for Django REST Framework
http://jpadilla.github.io/django-rest-framework-jwt/
MIT License
3.19k stars 651 forks source link

redis cache #475

Open yisen-cai opened 5 years ago

yisen-cai commented 5 years ago

I debug my django project these days, found every single request is calling authentication model query, could this too wasted. Query authentication model one time

When I using my Spring Boot project I always store the token in Redis, because redis is faster than database, in django, request.user is useful, store an object is best, I think if there is a way to store authentication model in redis as the first login time, set it's alive time, maybe few hours, time ended, data gone, when a new request come, query from redis, I think this could get an higher performance, thanks! And if there is chance, I want to add this code.

jadhavmanoj commented 5 years ago

@yisen718 you can use cacheops https://github.com/Suor/django-cacheops for storing auth model in Redis. Also, I don't think we should add code for storing auth model in the cache for this repository.

would love to hear thought on this if anyone has a suggestion or comments