educative.io

Educative

Why would we ignore the update if a replica already has the entry?

How can each cache replica be updated? Whenever there is a cache miss, our servers would be hitting a backend database. Whenever this happens, we can update the cache and pass the new entry to all the cache replicas. Each replica can update its cache by adding the new entry. If a replica already has that entry, it can simply ignore it.

why would we ignore the update if a replica already has the entry? the update should be the latest value. if a replica already has the entry, shouldn’t it overwrite the existing entry?

You cannot re-add the data in original replica set without re-syncing or rolling back the writes (which would undo your goal of writing data to this member).
That’s why we will ignore it.