Transferring session data from a custom database backend to a cache backend in Django

I have a Django application that uses user_sessions.backends.db for session management, which allows session objects to be accessed like ORM objects. However, I want to transition to using the cache as my SESSION_ENGINE for improved performance, thus eliminating the need for this library. My main concern is to change the session storage method while preserving the existing session data. The library only supports a database backend, so I will need to extend it to facilitate this migration. My plan includes: 1) examining the database tables where the session data is stored, 2) developing a method to migrate this data into cache memory during write operations, and 3) adjusting my application to read from the cache first, while keeping the database as a backup. Am I on the right track? I would appreciate any advice on pitfalls to avoid during this intricate process.

hey Ryan! your plan sounds solid! when switching to cache, how’re you handling concurrency & data consistency issues between db and cache? also have you considered security concerns with cache storage? maybe there’s a hybrid approach to explore? Would love to hear more about your implementation thoughts! :blush: