Expand description
Optimistic-concurrency read-modify-write over a JetStream KV key.
A blind kv.get → mutate → kv.put loses updates when two
writers race: both read the same snapshot, both put, and the
second put silently erases the first writer’s change. JetStream
KV’s update(key, value, revision) is a compare-and-swap — it
fails unless the key is still at the revision the caller read —
and create(key, value) is the matching CAS for “key must not
exist yet”. read_modify_write wraps both behind a re-read
retry loop so callers only supply the mutation.
Functions§
- read_
modify_ write - Read
key(missing or deleted →T::default()), applymutate, and write the result back guarded by the revision the read observed, retrying the whole round on a CAS conflict.