The check-and-set methods provide a mechanism for updating information only if the client knows the check (CAS) value. This can be used to prevent clients from updating values in the database that may have changed since the client obtained the value. Methods for storing and updating information support a CAS method that allows you to ensure that the client is updating the version of the data that the client retrieved.
The check value is in the form of a 64-bit integer which is updated every time the value is modified, even if the update of the value does not modify the binary data. Attempting to set or update a key/value pair where the CAS value does not match the value stored on the server will fail.
cas() methods are used to explicitly
set the value only if the CAS supplied by the client matches the
CAS on the server, analogous to the
Section 3.2, “Set Operations” method.
|Description||Compare and set a value providing the supplied CAS key matches|
|Document ID used to identify the value|
|Expiry time for key. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch).|
|Flags for storage options. Flags are ignored by the server byt preserved for use by the client.|
|Old value to be compared|
|Value to be stored|
The first form of the
cas() method allows
for an item to be set in the database only if the CAS value
supplied matches that stored on the server.
casr = membase.cas("caskey", casvalue, "new string value")