public Map<String, Object> get(String[] keys) { Future<Map<String, Object>> future = client.asyncGetBulk(tc, keys); try { return future.get(1, TimeUnit.SECONDS); } catch (Exception e) { future.cancel(false); } return Collections.<String, Object>emptyMap(); }
when(memcachedClient.asyncGetBulk(keyLookup.keySet())).thenReturn(bulkFuture); when(bulkFuture.get(cacheConfig.getTimeout(), TimeUnit.MILLISECONDS)).thenReturn(bulkResult);
@Override protected Cancellable bulkRestore(final Collection<String> storageKeys, final FutureCallback<Map<String, byte[]>> callback) { final BulkFuture<Map<String, Object>> future = client.asyncGetBulk(storageKeys); future.addListener(new BulkGetCompletionListener() { @Override public void onComplete(final BulkGetFuture<?> future) throws Exception { final Map<String, ?> storageObjectMap = future.get(); final Map<String, byte[]> resultMap = new HashMap<>(storageObjectMap.size()); for (final Map.Entry<String, ?> resultEntry: storageObjectMap.entrySet()) { resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue())); } callback.completed(resultMap); } }); return Operations.cancellable(future); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them * with the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them * with the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them * with the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keyIter Iterator that produces the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk( Iterator<String> keyIter) { return asyncGetBulk(keyIter, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keys the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk(Collection<String> keys) { return asyncGetBulk(keys, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keyIter Iterator that produces the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk( Iterator<String> keyIter) { return asyncGetBulk(keyIter, transcoder); }
/** * Asynchronously get a bunch of objects from the cache and decode them with * the given transcoder. * * @param keyIter Iterator that produces the keys to request * @return a Future result of that fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk( Iterator<String> keyIter) { return asyncGetBulk(keyIter, transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets with the default transcoder. * * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) { return asyncGetBulk(Arrays.asList(keys), transcoder); }
/** * Varargs wrapper for asynchronous bulk gets. * * @param tc the transcoder to serialize and unserialize value * @param keys one more more keys to get * @return the future values of those keys * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public <T> Future<Map<String, T>> asyncGetBulk(Transcoder<T> tc, String... keys) { return asyncGetBulk(Arrays.asList(keys), tc); }
@Override public Map<String, Object> get(String[] keys) { Future<Map<String, Object>> future = client.asyncGetBulk(tc, keys); try { return future.get(1, TimeUnit.SECONDS); } catch (Exception e) { future.cancel(false); } return Collections.<String, Object>emptyMap(); }