本文整理了Java中com.google.common.cache.Cache.putAll()
方法的一些代码示例,展示了Cache.putAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.putAll()
方法的具体详情如下:
包路径:com.google.common.cache.Cache
类名称:Cache
方法名:putAll
[英]Copies all of the mappings from the specified map to the cache. The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
[中]将所有映射从指定映射复制到缓存。对于指定映射中从键k到值v的每个映射,此调用的效果相当于在该映射上调用put(k,v)一次。如果在操作进行过程中修改了指定的映射,则此操作的行为未定义。
代码示例来源:origin: apache/incubator-druid
@Override
public void putAll(Map<? extends K, ? extends V> m)
{
cache.putAll(m);
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate.putAll(m);
}
代码示例来源:origin: google/guava
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: google/j2objc
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: ben-manes/caffeine
@Override
public void putAll(Map<? extends K, ? extends V> map) {
cache.putAll(map);
}
代码示例来源:origin: wildfly/wildfly
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: apache/incubator-gobblin
/**
* {@inheritDoc}.
*
* <p>
* If present in the cache, return the cached {@link com.typesafe.config.Config} for given input
* Otherwise, simply delegate the functionality to the internal {ConfigStoreValueInspector} and store the value into cache
* </p>
*/
@Override
public Map<ConfigKeyPath, Config> getOwnConfigs(Collection<ConfigKeyPath> configKeys) {
Collection<ConfigKeyPath> configKeysNotInCache = new ArrayList<>();
Map<ConfigKeyPath, Config> result = new HashMap<>();
for(ConfigKeyPath configKey: configKeys){
Config cachedValue = this.ownConfigCache.getIfPresent(configKey);
if(cachedValue==null){
configKeysNotInCache.add(configKey);
}
else{
result.put(configKey, cachedValue);
}
}
// for ConfigKeyPath which are not in cache
if(configKeysNotInCache.size()>0){
Map<ConfigKeyPath, Config> configsFromFallBack = this.valueFallback.getOwnConfigs(configKeysNotInCache);
this.ownConfigCache.putAll(configsFromFallBack);
result.putAll(configsFromFallBack);
}
return result;
}
代码示例来源:origin: google/guava
public void testPutAll() {
Cache<Integer, Integer> cache = CacheBuilder.newBuilder().build();
cache.putAll(ImmutableMap.of(10, 20, 30, 50, 60, 90));
assertEquals(Integer.valueOf(20), cache.getIfPresent(10));
assertEquals(Integer.valueOf(50), cache.getIfPresent(30));
assertEquals(Integer.valueOf(90), cache.getIfPresent(60));
cache.asMap().putAll(ImmutableMap.of(10, 50, 30, 20, 60, 70, 5, 5));
assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
assertEquals(Integer.valueOf(20), cache.getIfPresent(30));
assertEquals(Integer.valueOf(70), cache.getIfPresent(60));
assertEquals(Integer.valueOf(5), cache.getIfPresent(5));
}
代码示例来源:origin: apache/incubator-gobblin
this.recursiveConfigCache.putAll(configsFromFallBack);
result.putAll(configsFromFallBack);
代码示例来源:origin: prestodb/presto
@VisibleForTesting
void loadRecording()
throws IOException
{
Recording recording = new ObjectMapperProvider().get().readValue(new File(recordingPath), Recording.class);
allDatabases = recording.getAllDatabases();
databaseCache.putAll(toMap(recording.getDatabases()));
tableCache.putAll(toMap(recording.getTables()));
supportedColumnStatisticsCache.putAll(toMap(recording.getSupportedColumnStatistics()));
tableStatisticsCache.putAll(toMap(recording.getTableStatistics()));
partitionStatisticsCache.putAll(toMap(recording.getPartitionStatistics()));
allTablesCache.putAll(toMap(recording.getAllTables()));
allViewsCache.putAll(toMap(recording.getAllViews()));
partitionCache.putAll(toMap(recording.getPartitions()));
partitionNamesCache.putAll(toMap(recording.getPartitionNames()));
partitionNamesByPartsCache.putAll(toMap(recording.getPartitionNamesByParts()));
partitionsByNamesCache.putAll(toMap(recording.getPartitionsByNames()));
rolesCache.putAll(toMap(recording.getRoles()));
databasePrivilegesCache.putAll(toMap(recording.getDatabasePrivileges()));
tablePrivilegesCache.putAll(toMap(recording.getTablePrivileges()));
}
代码示例来源:origin: ben-manes/caffeine
public void testPutAll() {
Cache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder());
cache.putAll(ImmutableMap.of(10, 20, 30, 50, 60, 90));
assertEquals(Integer.valueOf(20), cache.getIfPresent(10));
assertEquals(Integer.valueOf(50), cache.getIfPresent(30));
assertEquals(Integer.valueOf(90), cache.getIfPresent(60));
cache.asMap().putAll(ImmutableMap.of(10, 50, 30, 20, 60, 70, 5, 5));
assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
assertEquals(Integer.valueOf(20), cache.getIfPresent(30));
assertEquals(Integer.valueOf(70), cache.getIfPresent(60));
assertEquals(Integer.valueOf(5), cache.getIfPresent(5));
}
代码示例来源:origin: ben-manes/caffeine
cache.putAll(ImmutableMap.of(1, 1, 2, 2, 3, 3));
cache.invalidateAll();
Arrays.fill(stats, 0);
代码示例来源:origin: apache/accumulo
private static Cache<String,Long> getPopulatedFileLenCache(Path dir, List<FileStatus> statuses) {
Map<String,Long> fileLens = getFileLenMap(statuses);
Map<String,Long> absFileLens = new HashMap<>();
fileLens.forEach((k, v) -> {
absFileLens.put(CachableBlockFile.pathToCacheId(new Path(dir, k)), v);
});
Cache<String,Long> fileLenCache = CacheBuilder.newBuilder().build();
fileLenCache.putAll(absFileLens);
return fileLenCache;
}
代码示例来源:origin: com.diffplug.guava/guava-cache
/**
* @since 12.0
*/
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public void putAll(Map<? extends K, ? extends V> m) {
memCacheMetadata.putAll(m.keySet());
memCache.putAll(m);
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* @since 12.0
*/
@Override
public void putAll(Map<? extends K,? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: org.eclipse.milo/sdk-client
public synchronized void setExpireAfter(long duration, TimeUnit unit) {
this.expireAfterNanos = unit.toNanos(duration);
Cache<NodeId, Map<AttributeId, DataValue>> newCache = buildCache();
newCache.putAll(cache.asMap());
cache = newCache;
}
代码示例来源:origin: org.eclipse.milo/sdk-client
public synchronized void setMaximumSize(long maximumSize) {
this.maximumSize = maximumSize;
Cache<NodeId, Map<AttributeId, DataValue>> newCache = buildCache();
newCache.putAll(cache.asMap());
cache = newCache;
}
代码示例来源:origin: org.hudsonci.lib.guava/guava
/**
* @since 12.0
*/
@Override
public void putAll(Map<? extends K,? extends V> m) {
delegate().putAll(m);
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/** @since 12.0 */
@Override
public void putAll(Map<? extends K, ? extends V> m) {
delegate().putAll(m);
}
内容来源于网络,如有侵权,请联系作者删除!