Compare-and-swap
Compare-and-swap is an atomic conditional update that replaces a stored value only if it matches an expected value and reports the comparison outcome or observed value.
The comparison and update must be indivisible; separate GET and PUT requests leave a race. In etcd, a transaction can compare a value or modification revision before its update. A value-only comparison cannot detect an intervening change that restores the original value; this is a constructed consequence of equality testing. A timeout can leave the operation's outcome unknown. This storage-API use of CAS is not content-addressable storage.
Relations
- related
- linearizability, serializability