We have been working with Django and Django RestFramework for quite a time now and facing a lot of challenging to manage cache in Redis, our models look like
(1) School (Details of School)
(2) Teacher (FK School, with all details of teacher)
(3) Student (FK Teacher, with all details of Teacher)
Our users would be operating CRUD operation on School, like /get_all_info should return a JSON object like,
{
"name": "something"
"teachers": [
{
"name": "teacher1 name",
"students": [
{
"name" : "student1 name"
}, ... all students of that teacher
]
}, ... all teacher of that school
]
}
Also, the whole system is very dynamic, each component keeps on changing. Around 90% of requests are of the type stated above.
We were thinking of adding post-save signals to delete full cache each time for the school like a student is updated in post-save first we will find his-her school then delete cache for that school. Is there is some more elegant/better approach? Is there any python library that can handle all this?