Usecase:
We've got a case where one of our models Content represents hierarchical data for our organization and for maintaining this hierarchy we've used django-mptt package which is based on the Modified Preorder Tree Transversal algorithm and for making the response time faster for the client, we've introduced the Redis Cache via django-cacheops package for our models.
Img src = http://www.sitepoint.com/hierarchical-data-database-2/
Problem:
As we've used MPTTModel for maintaining the hierarchical structure of our data inside the database, when concurrent CREATE and READ requests are made by the clients we end up with Corrupted data inside our Redis Cache.
Reason:
When we do a create operation on the tree, The MPTTModel Package actually creates the instance of the object inside the database and build/maintains the tree and while the MPTTModel package is building/maintaining the tree at the same time a read request is made to that instance which is then resulting in corrupted data inside the Redis Cache
Note:- our system architecture is based on Microservice Architecture due to which we've got a couple of requests being made by different Microservices.
Has anyone faced such an issue before and what solution can we use to resolve this problem?