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

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

本文整理了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

  1. @Override
  2. public Map<CacheKeyTO, CacheWrapper<Object>> mget(final Method method, final Set<CacheKeyTO> keys) throws CacheCenterConnectionException {
  3. if (null == keys || keys.isEmpty()) {
  4. return null;
  5. }
  6. Map<String, CacheKeyTO> keyMap = new HashMap<>(keys.size());
  7. for (CacheKeyTO key : keys) {
  8. keyMap.put(key.getCacheKey(), key);
  9. }
  10. Map<String, Object> values = memcachedClient.getBulk(keyMap.keySet());
  11. if (null == values || values.isEmpty()) {
  12. return null;
  13. }
  14. Map<CacheKeyTO, CacheWrapper<Object>> res = new HashMap<>(values.size());
  15. Iterator<Map.Entry<String, CacheKeyTO>> keyMapIt = keyMap.entrySet().iterator();
  16. while (keyMapIt.hasNext()) {
  17. Map.Entry<String, CacheKeyTO> item = keyMapIt.next();
  18. CacheWrapper<Object> value = (CacheWrapper<Object>) values.get(item.getKey());
  19. if (null != value) {
  20. res.put(item.getValue(), value);
  21. }
  22. }
  23. return res;
  24. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

相关文章