Put if absent?

by mindstream99 » Mon Aug 12, 2013 3:43 am

Is there a best practice for performing a put if absent operation that returns the existing value if it exists?

by young » Wed Aug 14, 2013 10:27 am

A two step process is used for 2.0 servers. We are making changes to the database in future versions that could do this in a single step.

WritePolicy policy = new WritePolicy();
policy.recordExistsAction = RecordExistsAction.FAIL;

try {
    client.put(policy, key, new Bin("bin", "value"));
}
catch (Exception e) {
    Record record = client.get(policy, key);
}