org.infinispan.Cache.putAsync()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.infinispan.Cache.putAsync()方法的一些代码示例,展示了Cache.putAsync()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.putAsync()方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:putAsync

Cache.putAsync介绍

暂无

代码示例

代码示例来源:origin: org.infinispan/infinispan-core

@Override
public <K> Future<?> perform(Cache<K, Object> cache, K key) {
 return cache.putAsync(key, finalValue());
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testAsyncOps() throws Exception {

   CompletableFuture<Object> result = cache.putAsync("k", "v");
   assert result.get() == null;

   result = cache.removeAsync("k");
   assert result.get().equals("v");

   final CompletableFuture<Void> voidNotifyingFuture = cache.putAllAsync(Collections.singletonMap("k", "v"));
   voidNotifyingFuture.get();

   assert cache.get("k").equals("v");
  }
}

代码示例来源:origin: org.infinispan/infinispan-server-hotrod

@TopologyChanged
 public void topologyChanged(TopologyChangedEvent<Address, ServerAddress> event) {
   boolean success = false;
   while (!success && !distributedExecutorService.isShutdown() && addressCache.getStatus().allowInvocations()) {
    try {
      List<CompletableFuture<Boolean>> futures = distributedExecutorService.submitEverywhere(
         new CheckAddressTask(clusterAddress));
      // No need for a timeout here, the distributed executor has a default task timeout
      AtomicBoolean result = new AtomicBoolean(true);
      futures.forEach(f -> {
       try {
         if (!f.get()) {
          result.set(false);
         }
       } catch (InterruptedException | ExecutionException e) {
         throw new CacheException(e);
       }
      });
      if (!result.get()) {
       log.debugf("Re-adding %s to the topology cache", clusterAddress);
       addressCache.putAsync(clusterAddress, address);
      }
      success = true;
    } catch (Throwable e) {
      log.debug("Error re-adding address to topology cache, retrying", e);
    }
   }
 }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testWithTx() throws Exception {
   TransactionManager transactionManager = TestingUtil.getTransactionManager(cache(0));
   cache(0).put("k","v1");
   transactionManager.begin();
   CompletableFuture<Object> future = cache(0).putAsync("k", "v2");
   "v1".equals(future.get(2000, TimeUnit.MILLISECONDS));
   transactionManager.commit();
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testPutAsync() throws Exception {
 CompletableFuture<String> f = c.putAsync("k", "v1");
 assertFutureResult(f, null);
 assertEquals("v1", c.get("k"));
 f = c.putAsync("k", "v2");
 assertFutureResult(f, "v1");
 assertEquals("v2", c.get("k"));
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core

cache.putAsync(changesKey, changesEntry.getValue());

代码示例来源:origin: org.infinispan/infinispan-core

public void testDefaultLifespanPutAsync() throws Exception {
 CompletableFuture<Object> f = cache().putAsync(1, "v1");
 f.get(10, TimeUnit.SECONDS);
 expectCachedThenExpired(1, "v1");
 f = cache().getAdvancedCache().putAsync(2, "v2", new EmbeddedMetadata.Builder().build());
 f.get(10, TimeUnit.SECONDS);
 expectCachedThenExpired(2, "v2");
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testPutAsyncWithLifespanAndMaxIdle() throws Exception {
 // lifespan only
 Future<String> f = c.putAsync("k", "v", 1000, TimeUnit.MILLISECONDS);
 markStartTime();
 assertFutureResult(f, null);
 verifyEviction("k", "v", 1000, 500, true);
 log.warn("STARTING FAILING ONE");
 // lifespan and max idle (test max idle)
 f = c.putAsync("k", "v", 3000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
 markStartTime();
 assertFutureResult(f, null);
 verifyEviction("k", "v", 1000, 500, false);
 // lifespan and max idle (test lifespan)
 f = c.putAsync("k", "v", 3000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
 markStartTime();
 assertFutureResult(f, null);
 verifyEviction("k", "v", 3000, 500, true);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testAsyncPut(Method m) throws Exception {
 Cache<Object, String> ownerCache = getOwner(k(m));
 ownerCache.put(k(m), v(m));
 CompletableFuture<String> f = ownerCache.putAsync(k(m), v(m, 1));
 assert f != null;
 assertEquals(v(m), f.get());
}

代码示例来源:origin: org.infinispan/infinispan-core

Future<String> f = c1.putAsync(key, v);
assert f != null;
Transaction t = tm.suspend();
f = c1.putAsync(key, v2);
assert f != null;
t = tm.suspend();

代码示例来源:origin: org.infinispan/infinispan-core

c.putAsync(e.getKey(), e.getValue() + "-other").get(10, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e1) {
 throw new AssertionError(e1);

代码示例来源:origin: org.infinispan/infinispan-query

public void testPutAsync() throws Exception {
 prepareTestData();
 SearchManager searchManager = Search.getSearchManager(cache2);
 QueryBuilder queryBuilder = searchManager
    .buildQueryBuilderForClass(Person.class)
    .get();
 Query allQuery = queryBuilder.all().createQuery();
 assertEquals(3, searchManager.getQuery(allQuery, Person.class).list().size());
 person4 = new Person();
 person4.setName("New Goat");
 person4.setBlurb("Also eats grass");
 Future f = cache2.putAsync("newGoat", person4);
 f.get();
 assertTrue(f.isDone());
 List<Person> found = searchManager.<Person>getQuery(allQuery, Person.class).list();
 assertEquals(4, found.size());
 assertTrue(found.contains(person4));
 Person person5 = new Person();
 person5.setName("Abnormal Goat");
 person5.setBlurb("Plays with grass.");
 f = cache2.putAsync("newGoat", person5);
 f.get();
 assertTrue(f.isDone());
 found = searchManager.<Person>getQuery(allQuery, Person.class).list();
 assertEquals(4, found.size());
 assertFalse(found.contains(person4));
 assertTrue(found.contains(person5));
 StaticTestingErrorHandler.assertAllGood(cache1, cache2);
}

代码示例来源:origin: org.infinispan/infinispan-core

EntryWrappingInterceptor.class);
Future<String> future = c1.putAsync(key, newValue);

代码示例来源:origin: org.infinispan/infinispan-core

put2 = cache.putAsync(key1, "v3");

相关文章