当前位置: 首页>>代码示例>>Java>>正文


Java OperationFuture.getCas方法代码示例

本文整理汇总了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);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例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);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例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);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例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);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例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);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:17,代码来源:BinarySpyMemcachedInstrumentationTest.java


注:本文中的net.spy.memcached.internal.OperationFuture.getCas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。