/** * Set a value and Observe. * * @param key the key to set * @param exp the Expiry value * @param value the Key value * @param req the Persistence to Master value * @param rep the Persistence to Replicas * @return whether or not the operation was performed */ public OperationFuture<Boolean> set( String key, int exp, String value, PersistTo req, ReplicateTo rep) { OperationFuture<Boolean> setOp = set(key, exp, value); try { if (setOp.get()) { observePoll(key, setOp.getCas(), req, rep); } } catch (InterruptedException e) { setOp.set(false, setOp.getStatus()); } catch (ExecutionException e) { setOp.set(false, setOp.getStatus()); } catch (TimeoutException e) { setOp.set(false, setOp.getStatus()); } catch (IllegalArgumentException e) { setOp.set(false, setOp.getStatus()); } catch (RuntimeException e) { setOp.set(false, setOp.getStatus()); } return (setOp); }
public void testSetReturnsCAS() throws Exception { OperationFuture<Boolean> setOp = client.set("testSetReturnsCAS", 0, "testSetReturnsCAS"); setOp.get(); assertTrue(setOp.getCas() > 0); }