Complete the code to define a consistency model where all reads see the latest write.
consistency_model = "[1]" # Ensures all reads see the latest write
Strong consistency means every read returns the most recent write.
Complete the code to define a consistency model where updates propagate over time.
consistency_model = "[1]" # Updates may not be immediately visible
Eventual consistency means updates will be visible after some time delay.
Fix the error in the code to correctly represent a strong consistency check.
if read_value == [1]: # Check if read matches latest write
Strong consistency requires the read to match the latest write.
Fill both blanks to complete the description of eventual consistency behavior.
while not [1]: # Wait until [2] is visible to all nodes sleep(1)
Eventual consistency waits until all nodes are updated with the latest update.
Fill all three blanks to complete the code snippet illustrating consistency model selection.
def select_consistency_model(require_strong): if require_strong: return "[1]" else: return "[2]" # [3] consistency allows delays
The function returns strong consistency if required, otherwise eventual consistency which allows delays.