compareAndSet

abstract suspend fun compareAndSet(key: String, expected: String?, new: String): Boolean(source)

Atomically sets key to new only if its current value equals expected (null meaning "absent"). Returns whether the update happened — the building block for distributed counters/state machines.