Skip to main content

read_modify_write

Function read_modify_write 

Source
pub async fn read_modify_write<T, F>(
    kv: &Store,
    key: &str,
    mutate: F,
) -> Result<T>
Expand description

Read key (missing or deleted → T::default()), apply mutate, and write the result back guarded by the revision the read observed, retrying the whole round on a CAS conflict.

mutate returning false means “no change needed” — the current value is returned without a write (so no-op adds/removes don’t bump the key’s revision or wake watchers).

Returns the value as written (or as read, for a no-op).