com.google.common.cache.Cache.getAllPresent()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(462)

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

Cache.getAllPresent介绍

[英]Returns a map of the values associated with keys in this cache. The returned map will only contain entries which are already present in the cache.
[中]返回与此缓存中的键关联的值的映射。返回的映射将只包含缓存中已存在的条目。

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
public Map<K, V> getAllPresent(Iterable<K> keys)
{
 return cache.getAllPresent(keys);
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
  return delegate.getAllPresent(keys);
}

代码示例来源:origin: google/guava

/** @since 11.0 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: google/j2objc

/** @since 11.0 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: wildfly/wildfly

/** @since 11.0 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: google/guava

public void testGetAllPresent() throws ExecutionException {
 when(mock.getAllPresent(ImmutableList.of("key")))
   .thenReturn(ImmutableMap.of("key", Boolean.TRUE));
 assertEquals(
   ImmutableMap.of("key", Boolean.TRUE), forward.getAllPresent(ImmutableList.of("key")));
}

代码示例来源:origin: google/guava

public void testGetAllPresent_empty() {
 Cache<Object, Object> cache =
   new AbstractCache<Object, Object>() {
    @Override
    public Object getIfPresent(Object key) {
     return null;
    }
   };
 assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.of(new Object())));
}

代码示例来源:origin: ben-manes/caffeine

@Override
public Map<K, V> getAllPresent(Iterable<?> keys) {
 requireNonNull(keys);
 keys.forEach(Objects::requireNonNull);
 return cache.getAllPresent(keys);
}

代码示例来源:origin: google/guava

public void testGetAllPresent_cached() {
 final Object cachedKey = new Object();
 final Object cachedValue = new Object();
 Cache<Object, Object> cache =
   new AbstractCache<Object, Object>() {
    @Override
    public Object getIfPresent(Object key) {
     return cachedKey.equals(key) ? cachedValue : null;
    }
   };
 assertEquals(
   ImmutableMap.of(cachedKey, cachedValue),
   cache.getAllPresent(ImmutableList.of(cachedKey, new Object())));
}

代码示例来源:origin: google/guava

assertEquals(0, stats.hitCount());
assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.<Integer>of()));
stats = cache.stats();
assertEquals(0, stats.missCount());
assertEquals(0, stats.hitCount());
assertEquals(ImmutableMap.of(), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(ImmutableMap.of(2, 22), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(5, stats.missCount());
assertEquals(ImmutableMap.of(2, 22, 3, 33), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(6, stats.missCount());
assertEquals(ImmutableMap.of(1, 11, 2, 22, 3, 33), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(6, stats.missCount());

代码示例来源:origin: ben-manes/caffeine

assertEquals(0, stats.hitCount());
assertEquals(ImmutableMap.of(), cache.getAllPresent(ImmutableList.<Integer>of()));
stats = cache.stats();
assertEquals(0, stats.missCount());
assertEquals(0, stats.hitCount());
assertEquals(ImmutableMap.of(), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(ImmutableMap.of(2, 22), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(5, stats.missCount());
assertEquals(ImmutableMap.of(2, 22, 3, 33), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(6, stats.missCount());
assertEquals(ImmutableMap.of(1, 11, 2, 22, 3, 33), cache.getAllPresent(asList(1, 2, 3)));
stats = cache.stats();
assertEquals(6, stats.missCount());

代码示例来源:origin: apache/samza

@Override
public CompletableFuture<Map<K, V>> getAllAsync(List<K> keys) {
 CompletableFuture<Map<K, V>> future = new CompletableFuture<>();
 try {
  future.complete(cache.getAllPresent(keys));
 } catch (Exception e) {
  future.completeExceptionally(e);
 }
 return future;
}

代码示例来源:origin: org.apache.samza/samza-core_2.12

@Override
public CompletableFuture<Map<K, V>> getAllAsync(List<K> keys) {
 CompletableFuture<Map<K, V>> future = new CompletableFuture<>();
 try {
  future.complete(cache.getAllPresent(keys));
 } catch (Exception e) {
  future.completeExceptionally(e);
 }
 return future;
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * @since 11.0
 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/**
 * @since 11.0
 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<? extends K> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/**
 * @since 11.0
 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * @since 11.0
 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * @since 11.0
 */
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
 return delegate().getAllPresent(keys);
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public ImmutableMap<K, V> getAllPresent(
    Iterable<?> keys) {
  Iterable<K> typedKeys = (Iterable<K>) keys;
  memCacheMetadata.incrementAll(keys);
  ImmutableMap<K, V> result = memCache.getAllPresent(keys);
  memCacheMetadata.removeAll(filter(typedKeys, not(in(result.keySet()))));
  return result;
}

代码示例来源:origin: com.google.guava/guava-tests

public void testGetAllPresent_empty() {
 Cache<Object, Object> cache = new AbstractCache<Object, Object>() {
  @Override
  public Object getIfPresent(Object key) {
   return null;
  }
 };
 assertEquals(
   ImmutableMap.of(),
   cache.getAllPresent(ImmutableList.of(new Object())));
}

相关文章