本文整理汇总了Java中net.spy.memcached.internal.OperationFuture.getCas方法的典型用法代码示例。如果您正苦于以下问题:Java OperationFuture.getCas方法的具体用法?Java OperationFuture.getCas怎么用?Java OperationFuture.getCas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.spy.memcached.internal.OperationFuture
的用法示例。
在下文中一共展示了OperationFuture.getCas方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAppendCas
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Test
public void testAppendCas() throws Exception {
String value = UUID.randomUUID().toString();
OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
Boolean didSet = setFuture.get();
assertTrue(didSet);
Long cas = setFuture.getCas();
Snapshot expectedValues = tracker.snapshot();
expectedValues.increment("append");
String value1 = UUID.randomUUID().toString();
Boolean appended = memcacheClient.append(cas, "key", value1).get();
assertTrue(appended);
tracker.validate(expectedValues);
Object val = memcacheClient.get("key");
assertEquals(value + value1, val);
}
示例2: testPrependCas
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Test
public void testPrependCas() throws Exception {
String value = UUID.randomUUID().toString();
OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
Boolean didSet = setFuture.get();
assertTrue(didSet);
Long cas = setFuture.getCas();
Snapshot expectedValues = tracker.snapshot();
expectedValues.increment("prepend");
String value1 = UUID.randomUUID().toString();
Boolean appended = memcacheClient.prepend(cas, "key", value1).get();
assertTrue(appended);
tracker.validate(expectedValues);
Object val = memcacheClient.get("key");
assertEquals(value1 + value, val);
}
示例3: testAsyncCas
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Test
public void testAsyncCas() throws Exception {
String value = UUID.randomUUID().toString();
OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
Boolean didSet = setFuture.get();
assertTrue(didSet);
Long cas = setFuture.getCas();
Snapshot expectedValues = tracker.snapshot();
expectedValues.increment("set");
String value1 = UUID.randomUUID().toString();
CASResponse response = memcacheClient.asyncCAS("key", cas, value1).get();
assertEquals(CASResponse.OK, response);
tracker.validate(expectedValues);
Object val = memcacheClient.get("key");
assertEquals(value1, val);
}
示例4: testCas
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Test
public void testCas() throws Exception {
String value = UUID.randomUUID().toString();
OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
Boolean didSet = setFuture.get();
assertTrue(didSet);
Long cas = setFuture.getCas();
Snapshot expectedValues = tracker.snapshot();
expectedValues.increment("set");
String value1 = UUID.randomUUID().toString();
CASResponse response = memcacheClient.cas("key", cas, value1);
assertEquals(CASResponse.OK, response);
tracker.validate(expectedValues);
Object val = memcacheClient.get("key");
assertEquals(value1, val);
}
示例5: testDeleteCas
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Test
public void testDeleteCas() throws Exception {
String value = UUID.randomUUID().toString();
OperationFuture<Boolean> future = memcacheClient.set("key", 0, value);
assertTrue(future.get());
long cas = future.getCas();
Snapshot expectedValues = tracker.snapshot();
expectedValues.increment("delete");
Boolean deleted = memcacheClient.delete("key", cas).get();
assertTrue(deleted);
tracker.validate(expectedValues);
Object val = memcacheClient.get("key");
assertNull(val);
}