use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testAppend.
@Test
public void testAppend() throws Exception {
MemcachedClient client = bootstrapClient();
Future<Boolean> b = client.append(0, "key", "WithAddition");
assertTrue(b.get());
assertEquals("myStringValueWithAddition", client.get("key"));
b = client.append(0, "appendkey", "val");
assertFalse(b.get());
assertNull(client.get("appendkey"));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testDecr.
@Test
public void testDecr() throws Exception {
MemcachedClient client = bootstrapClient();
client.add("decrkey", 10, 99).get();
assertEquals(95, client.decr("decrkey", 4));
assertEquals(94, client.decr("decrkey", 1));
assertEquals(-1, client.decr("decrkey1", 77));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testGets.
@Test
public void testGets() throws Exception {
MemcachedClient client = bootstrapClient();
client.add("getskey", 10, "casValue").get();
CASValue<Object> val = client.gets("getskey");
long oldCas = val.getCas();
assertEquals("casValue", val.getValue());
client.replace("getskey", 10, "myNewVal").get();
val = client.gets("getskey");
assertEquals(oldCas + 1, val.getCas());
assertEquals("myNewVal", val.getValue());
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method testLongExpiration.
@Test
public void testLongExpiration() throws Exception {
MemcachedClient client = bootstrapClient();
client.add("newKey", (int) System.currentTimeMillis() - 60 * 1000, "newValue");
Thread.sleep(15 * 1000);
assertEquals("newValue", client.get("newKey"));
}
use of net.spy.memcached.MemcachedClient in project geode by apache.
the class GemcachedDevelopmentJUnitTest method bootstrapClient.
private MemcachedClient bootstrapClient() throws IOException, UnknownHostException, InterruptedException, ExecutionException {
MemcachedClient client = createMemcachedClient();
Future<Boolean> f = client.add("key", 10, "myStringValue");
f.get();
Future<Boolean> f1 = client.add("key1", 10, "myStringValue1");
f1.get();
return client;
}
Aggregations