net.spy.memcached.MemcachedClient.getBulk()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(140)

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

MemcachedClient.getBulk介绍

[英]Get the values for multiple keys from the cache.
[中]从缓存中获取多个键的值。

代码示例

代码示例来源:origin: qiujiayu/AutoLoadCache

@Override
public Map<CacheKeyTO, CacheWrapper<Object>> mget(final Method method, final Set<CacheKeyTO> keys) throws CacheCenterConnectionException {
  if (null == keys || keys.isEmpty()) {
    return null;
  }
  Map<String, CacheKeyTO> keyMap = new HashMap<>(keys.size());
  for (CacheKeyTO key : keys) {
    keyMap.put(key.getCacheKey(), key);
  }
  Map<String, Object> values = memcachedClient.getBulk(keyMap.keySet());
  if (null == values || values.isEmpty()) {
    return null;
  }
  Map<CacheKeyTO, CacheWrapper<Object>> res = new HashMap<>(values.size());
  Iterator<Map.Entry<String, CacheKeyTO>> keyMapIt = keyMap.entrySet().iterator();
  while (keyMapIt.hasNext()) {
    Map.Entry<String, CacheKeyTO> item = keyMapIt.next();
    CacheWrapper<Object> value = (CacheWrapper<Object>) values.get(item.getKey());
    if (null != value) {
      res.put(item.getValue(), value);
    }
  }
  return res;
}

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

public Map<String, Object> getAll(final Collection<String> keys) {
  final Map<String, Object> map = client.getBulk(keys);
  final Map<String, Object> translated = new LinkedHashMap<>();
  map.forEach((key, value) -> translated.put(key, fromCacheValue(value)));
  return translated;
}

代码示例来源:origin: apache/httpcomponents-client

@Override
protected Map<String, byte[]> bulkRestore(final Collection<String> storageKeys) throws ResourceIOException {
  final Map<String, ?> storageObjectMap = client.getBulk(storageKeys);
  final Map<String, byte[]> resultMap = new HashMap<>(storageObjectMap.size());
  for (final Map.Entry<String, ?> resultEntry: storageObjectMap.entrySet()) {
    resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue()));
  }
  return resultMap;
}

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Map<String, Object> getBulk(Collection<String> keys) {
  return getBulk(keys, transcoder);
}

代码示例来源:origin: com.google.code.simple-spring-memcached/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
public Map<String, Object> getBulk(Collection<String> keys) {
 return getBulk(keys, transcoder);
}

代码示例来源:origin: com.google.code.simple-spring-memcached/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keyIter Iterator that produces the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
public Map<String, Object> getBulk(Iterator<String> keyIter) {
 return getBulk(keyIter, transcoder);
}

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Map<String, Object> getBulk(Collection<String> keys) {
  return getBulk(keys, transcoder);
}

代码示例来源:origin: net.spy/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keyIter Iterator that produces the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public Map<String, Object> getBulk(Iterator<String> keyIter) {
 return getBulk(keyIter, transcoder);
}

代码示例来源:origin: net.spy/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public Map<String, Object> getBulk(Collection<String> keys) {
 return getBulk(keys, transcoder);
}

代码示例来源:origin: naver/arcus-java-client

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *                                   exceeded
 * @throws IllegalStateException     in the rare circumstance where queue
 *                                   is too full to accept any more requests
 */
public Map<String, Object> getBulk(Collection<String> keys) {
 return getBulk(keys, transcoder);
}

代码示例来源:origin: com.amazonaws/elasticache-java-cluster-client

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public Map<String, Object> getBulk(Collection<String> keys) {
 return getBulk(keys, transcoder);
}

代码示例来源:origin: com.google.code.simple-spring-memcached/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
public Map<String, Object> getBulk(String... keys) {
 return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: com.amazonaws/elasticache-java-cluster-client

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public Map<String, Object> getBulk(String... keys) {
 return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: com.google.code.maven-play-plugin.spy/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Map<String, Object> getBulk(String... keys) {
  return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Map<String, Object> getBulk(String... keys) {
  return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: net.spy/spymemcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public Map<String, Object> getBulk(String... keys) {
 return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: naver/arcus-java-client

/**
 * Get the values for multiple keys from the cache.
 *
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *                                   exceeded
 * @throws IllegalStateException     in the rare circumstance where queue
 *                                   is too full to accept any more requests
 */
public Map<String, Object> getBulk(String... keys) {
 return getBulk(Arrays.asList(keys), transcoder);
}

代码示例来源:origin: com.google.code.maven-play-plugin.spy/memcached

/**
 * Get the values for multiple keys from the cache.
 *
 * @param tc the transcoder to serialize and unserialize value
 * @param keys the keys
 * @return a map of the values (for each value that exists)
 * @throws OperationTimeoutException if the global operation timeout is
 *           exceeded
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public <T> Map<String, T> getBulk(Transcoder<T> tc, String... keys) {
  return getBulk(Arrays.asList(keys), tc);
}

代码示例来源:origin: org.apache.httpcomponents.client5/httpclient5-cache

@Override
protected Map<String, byte[]> bulkRestore(final Collection<String> storageKeys) throws ResourceIOException {
  final Map<String, ?> storageObjectMap = client.getBulk(storageKeys);
  final Map<String, byte[]> resultMap = new HashMap<>(storageObjectMap.size());
  for (final Map.Entry<String, ?> resultEntry: storageObjectMap.entrySet()) {
    resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue()));
  }
  return resultMap;
}

代码示例来源:origin: io.snappydata/gemfire-junit

public void testMultiGet() throws Exception {
 MemcachedClient client = bootstrapClient();
 Map<String, Object> val = client.getBulk("key", "key1");
 assertEquals(2, val.size());
 assertEquals("myStringValue", val.get("key"));
 assertEquals("myStringValue1", val.get("key1"));
 client.add("Hello", 0, "World");
 Thread.sleep(1100);
 assertEquals("World", client.get("Hello"));
}

相关文章