本文整理了Java中io.vertx.core.shareddata.AsyncMap.put()
方法的一些代码示例,展示了AsyncMap.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AsyncMap.put()
方法的具体详情如下:
包路径:io.vertx.core.shareddata.AsyncMap
类名称:AsyncMap
方法名:put
AsyncMap.put介绍
[英]Like #put but specifying a time to live for the entry. Entry will expire and get evicted after the ttl.
[中]类似于#put,但指定条目的生存时间。条目将在ttl之后过期并被逐出。
代码示例
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public void put(K k, V v, Handler> completionHandler) {
checkType(k);
checkType(v);
delegate.put(k, v, completionHandler);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Override
public void put(K k, V v, long timeout, Handler> completionHandler) {
checkType(k);
checkType(v);
delegate.put(k, v, timeout, completionHandler);
}
代码示例来源:origin: eclipse-vertx/vert.x
protected void loadData(Map map, BiConsumer> test) {
List futures = new ArrayList<>(map.size());
map.forEach((key, value) -> {
Future future = Future.future();
getVertx().sharedData().getAsyncMap("foo", onSuccess(asyncMap -> {
asyncMap.put(key, value, future);
}));
futures.add(future);
});
CompositeFuture.all(futures).setHandler(onSuccess(cf -> {
Vertx v = getVertx();
v.sharedData().getAsyncMap("foo", onSuccess(asyncMap -> {
test.accept(v, asyncMap);
}));
}));
}
代码示例来源:origin: io.vertx/vertx-core
@Override
public void put(K k, V v, long timeout, Handler> completionHandler) {
checkType(k);
checkType(v);
delegate.put(k, v, timeout, completionHandler);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testPutNullKey() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put(null, "foo", ar2 -> {}));
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testPutNullValue() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put("foo", null, ar2 -> {}));
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testPutInvalidKey() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put(new SomeObject(), "foo", ar2 -> {}));
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testPutInvalidValue() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put("foo", new SomeObject(), ar2 -> {}));
testComplete();
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMapPutTtlThenPut() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put("pipo", "molo", 10, onSuccess(vd -> {
map.put("pipo", "mili", onSuccess(vd2 -> {
vertx.setTimer(20, l -> {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.get("pipo", onSuccess(res -> {
assertEquals("mili", res);
testComplete();
}));
}));
});
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSize() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.size(onSuccess(size -> {
assertEquals(0, size.intValue());
map.put("foo", "bar", onSuccess(v -> {
map.size(onSuccess(size2 -> {
assertEquals(1, size2.intValue());
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.size(onSuccess(size3 -> {
assertEquals(1, size3.intValue());
testComplete();
}));
}));
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testMapPutGet(K k, V v) {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put(k, v, onSuccess(vd -> {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.get(k, onSuccess(res -> {
assertEquals(v, res);
testComplete();
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMultipleMaps() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put("foo", "bar", onSuccess(v -> {
getVertx().sharedData().getAsyncMap("bar", onSuccess(map2 -> {
map2.get("foo", onSuccess(res -> {
assertNull(res);
testComplete();
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testMapRemove(K k, V v) {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put(k, v, onSuccess(res -> {
assertNull(res);
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.remove(k, onSuccess(res2 -> {
assertEquals(v, res2);
testComplete();
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMapPutTtl() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put("pipo", "molo", 10, onSuccess(vd -> {
vertx.setTimer(15, l -> {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.get("pipo", onSuccess(res -> {
assertNull(res);
testComplete();
}));
}));
});
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testClear() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put("foo", "bar", onSuccess(v -> {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.clear(onSuccess(v2 -> {
map.get("foo", onSuccess(res -> {
assertNull(res);
testComplete();
}));
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testMapRemoveIfPresent(K k, V v, V other) {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put(k, v, onSuccess(res -> {
assertNull(res);
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.removeIfPresent(k, other, onSuccess(res2 -> {
assertFalse(res2);
map2.removeIfPresent(k, v, onSuccess(res3 -> {
assertTrue(res3);
testComplete();
}));
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testMapReplaceIfPresent(K k, V v, V other) {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put(k, v, onSuccess(res -> {
assertNull(res);
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.replaceIfPresent(k, v, other, onSuccess(res2 -> {
map2.replaceIfPresent(k, v, other, onSuccess(res3 -> {
assertFalse(res3);
map2.get(k, onSuccess(res4 -> {
assertEquals(other, res4);
testComplete();
}));
}));
}));
}));
}));
}));
await();
}
代码示例来源:origin: eclipse-vertx/vert.x
private void testMapReplace(K k, V v, V other) {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
map.put(k, v, onSuccess(res -> {
assertNull(res);
getVertx().sharedData().getAsyncMap("foo", onSuccess(map2 -> {
map2.replace(k, other, onSuccess(res2 -> {
assertEquals(v, res2);
map2.get(k, onSuccess(res3 -> {
assertEquals(other, res3);
map2.remove(k, onSuccess(res4 -> {
map2.replace(k, other, onSuccess(res5 -> {
assertNull(res5);
map2.get(k, onSuccess(res6 -> {
assertNull(res6);
testComplete();
}));
}));
}));
}));
}));
}));
}));
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testPutNullKey() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put(null, "foo", ar2 -> {}));
testComplete();
}));
await();
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testPutInvalidKey() {
getVertx().sharedData().getAsyncMap("foo", onSuccess(map -> {
assertIllegalArgumentException(() -> map.put(new SomeObject(), "foo", ar2 -> {}));
testComplete();
}));
await();
}