@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; }
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; }
@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; }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
@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; }
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")); }