In these two videos (Udacity Web Development Course):
https://www.youtube.com/watch?v=wgDSWe9Aq34
https://www.youtube.com/watch?v=j91-ActFe8w
It's explained that cas prevents overwrites. (an overwrite being when one app's write to memcache "squashes" another app's write to memcache) Cas prevents this essentially by checking whats in the cache and seeing if it has changed between get calls before it writes to the cache. What I don't understand is how this prevents 2 apps from writing at the same time. If both apps get the hash value at the same time (from the get function) they would both have the same hash value. Then they both enter their cas functions at the same time and check that the get values are the same (which they still are because neither has written to the cache), and then write at the same time with one still having the potential to "squash" the other write to memcache. Is the idea just to make overwrites less likely? Or am I misunderstanding the logic of the process.
Aucun commentaire:
Enregistrer un commentaire