I have taken a database class this semester and we are studying about maintaining cache consistency between the RDBMS and a cache server such as memcached. The consistency issues arise when there are race conditions. For example:
- Suppose I do a
get(key)
from the cache and there is a cache miss. Because I get a cache miss, I fetch the data from the database, and then do aput(key,value)
into the cache. - But, a race condition might happen, where some other user might delete the data I fetched from the database. This delete might happen before I do a
put
into the cache.
Thus, ideally the put
into the cache should not happen, since the data is longer present in the database.
If the cache entry has a TTL, the entry in the cache might expire. But still, there is a window where the data in the cache is inconsistent with the database.
I have been searching for articles/research papers which speak about this kind of issues. But, I could not find any useful resources.