Thursday, August 30, 2018

Re: Customise Session Engine to distribute session data storage

We were actually cache_db but the sessions were consuming too much of DB. Hence, we want some sessions to be persistent in DB and some to be volatile and not stored in DB. Hence, I was looking for some way to achieve that. Like I want all login sessions to be stored in DB whereas rest in cache. 

On Tuesday, August 28, 2018 at 4:37:46 PM UTC+5:30, Jason wrote:
Actually, there's nothing stopping you from using redis for cache and session cache.  

SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

will use your cache to store sessions.  and if you use cached_db instead of cache, that data will persist in redis and survive restarts.

On Tuesday, August 28, 2018 at 1:40:38 AM UTC-4, Web Architect wrote:
Hi Jason,

Thanks for the response. Why not use Django's cache backend and setting cache alias to be redis?

Thanks. 

On Monday, August 27, 2018 at 5:01:08 PM UTC+5:30, Jason wrote:
there's an option to use redis as a session backend, which would be faster than using a regular db, even a well tuned mysql/postgres instance

https://github.com/martinrusev/django-redis-sessions

On Monday, August 27, 2018 at 3:52:06 AM UTC-4, Web Architect wrote:
Hi,

Right now we are using the Django cache_db session engine for persistent sessions and also for some speed. Is it possible to customise this where I can store some session data in cache and some in DB? For example, I want to store all login sessions in DB and rest like some user specific data - basket etc in cache .

Looking forward to your support....

Thanks. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/86d58e15-ff41-48e3-b534-2bf982d59531%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment