Write unique record


In the C API, in write parameters there is a property to ensure that a write will only succeed if the record did not exist before.

cl_write_parameters; { … // write unique - will only succeed if record didn’t exist before bool unique;
… }

How do I do the same thing with the libevent API?


Hi Jene,

Yes, that flag isn’t currently in the libevent client API. But you can achieve the same behavior by using the ‘use_generation’ and ‘generation’ fields in ev2citrusleaf_write_parameters. Just set ‘use_generation’ to true and ‘generation’ to 0, and the write transaction will fail if the record already exists. The one difference is that the error returned will be EV2CITRUSLEAF_FAIL_GENERATION as opposed to EV2CITRUSLEAF_FAIL_KEY_EXISTS.