Open googlespot opened 4 years ago
Can describe use-case and what compact-and-swap api should do?
virtual status replace(string_view key, string_view expect_value, string_view value) = 0;
we already have similar idea for API extension: https://github.com/pmem/pmemkv/issues/387 but it will work only for values that do not require reallocation - will it work for your use-case?
compare and swap is different than update. Update is not conditional, whereas CAS is. This makes it a bit more difficult to implement atomically.
@pbalcer yes, but the isue linked by szyrom discusses several possible approaches (the last example in the first comment is what would allow CAS). However, it would be quite complicated to implement that and came up with a reasonable API so for now we only plan to do a regular, not conditional update.
Concurrent scenarios are difficult to use because there is no compact-and-swap interface.