Can I specify CAS value and durability requirements together in a store operation?



I need to store a value, provided the data under its key has not been modified in the DB since the value was read, and be sure the new value is persisted/replicated to a certain number of nodes. For modification check, I’d like to utilize optimistic locking, i.e. CAS methods. I need to synchronously wait until persistence/replication of the value is successful.

Problem is that .NET SDK provides methods to specify either a CAS value or durability requirements:

ExecuteCas(mode, key, value, validfor, cas);
ExecuteStore(mode, key, value, persistTo, replicateTo);

I need to combine both. There is also Observe method:

Observe(key, cas, persistTo, replicateTo);

but seems that it is not documented. So, particularly, I can’t be sure if the method waits for the value to be persisted/replicated or just checks that at the moment of the call.


@Eugene -

You should be able to use Observe to do what you want. Observe will wait until the desired constraints are reached (ReplicateTo and PersistTo) and the CAS value will be used to ensure that the key hasn’t changed.

You could also do the same by combining ExecuteStore and ExecuteCas and providing the logic required to meet your specifications.



Jeff, thank you for the explanation! I will use the Observe method.

It would be good if the method was documented somewhere in the .NET SDK docs (