I found this question in StackOverFlow and I can't understand the reason of not caching. I am very new to web programming so i would be glad if someone can answer me this.
Asked
Active
Viewed 51 times
1 Answers
2
Here is an example.
User-1 views the count of item-x and sees 1 is still remaining. Backend caches this result for a minute.
Within the next 30 seconds, another User-2 buys the item.
After 30 seconds, User_1 finally decides to buy the item. He views again the stock count, which is the cached value of 1. This is already outdated because another User-2 has already bought item-x a few seconds ago.
Thus, we now have inconsistent data, where the database has 0 count for item-x already while our cache still has the outdated 1 count. User_1 is seeing a value that is not up-to-date.

Niel Godfrey Pablo Ponciano
- 9,822
- 1
- 17
- 30