@Override protected Cancellable getForUpdateCAS(final String storageKey, final FutureCallback<CASValue<Object>> callback) { return operation(client.asyncGets(storageKey), callback); }
/** * Gets (with CAS support) the given key asynchronously and decode using the * default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public OperationFuture<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
/** * Gets (with CAS support) the given key asynchronously and decode using * the default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
/** * Gets (with CAS support) the given key asynchronously and decode using * the default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
/** * Gets (with CAS support) the given key asynchronously and decode using the * default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
/** * Gets (with CAS support) the given key asynchronously and decode using the * default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public OperationFuture<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
/** * Gets (with CAS support) the given key asynchronously and decode using * the default transcoder. * * @param key the key to fetch * @return a future that will hold the return value of the fetch * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public Future<CASValue<Object>> asyncGets(final String key) { return asyncGets(key, transcoder); }
@Override protected Cancellable getForUpdateCAS(final String storageKey, final FutureCallback<CASValue<Object>> callback) { return operation(client.asyncGets(storageKey), callback); }
/** * Gets (with CAS support) with a single key. * * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is * exceeded * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get( operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { throw new RuntimeException("Exception waiting for value", e); } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Gets (with CAS support) with a single key. * * @param <T> * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is * exceeded * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get( operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { throw new RuntimeException("Exception waiting for value", e); } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Gets (with CAS support) with a single key. * * @param <T> * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is * exceeded * @throws IllegalStateException in the rare circumstance where queue * is too full to accept any more requests */ public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get( operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { throw new RuntimeException("Exception waiting for value", e); } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Gets (with CAS support) with a single key. * * @param <T> * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is exceeded * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { throw new RuntimeException("Exception waiting for value", e); } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Gets (with CAS support) with a single key. * * @param <T> * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is exceeded * @throws CancellationException if operation was canceled * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { if(e.getCause() instanceof CancellationException) { throw (CancellationException) e.getCause(); } else { throw new RuntimeException("Exception waiting for value", e); } } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Gets (with CAS support) with a single key. * * @param <T> * @param key the key to get * @param tc the transcoder to serialize and unserialize value * @return the result from the cache and CAS id (null if there is none) * @throws OperationTimeoutException if global operation timeout is exceeded * @throws CancellationException if operation was canceled * @throws IllegalStateException in the rare circumstance where queue is too * full to accept any more requests */ @Override public <T> CASValue<T> gets(String key, Transcoder<T> tc) { try { return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new RuntimeException("Interrupted waiting for value", e); } catch (ExecutionException e) { if(e.getCause() instanceof CancellationException) { throw (CancellationException) e.getCause(); } else { throw new RuntimeException("Exception waiting for value", e); } } catch (TimeoutException e) { throw new OperationTimeoutException("Timeout waiting for value", e); } }
/** * Looks up the namespace for the given context name in the cache. * * @param context Context name. * * @return Corresponding namespace for given context or null if no namespace exists for context. * * @throws java.io.IOException On memcached operation errors. */ protected String lookupNamespace(final String context) throws IOException { try { final CASValue<String> result = handleAsyncResult( memcacheClient.asyncGets(memcachedKey(context), stringTranscoder)); return result == null ? null : result.getValue(); } catch (RuntimeException e) { throw new IOException("Memcached operation failed", e); } }
memcacheClient.asyncGets(namespace + CTX_KEY_LIST_SUFFIX, stringTranscoder)); if (keys == null) { logger.debug("No context keys found to update expiration"); memcacheClient.asyncGets(namespace + CTX_KEY_BLACKLIST_SUFFIX, stringTranscoder)); if (blacklistKeys != null) { keySet.removeAll(Arrays.asList(blacklistKeys.getValue().split(CTX_KEY_LIST_DELIMITER)));
/** {@inheritDoc} */ @Override public StorageRecord read(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key) throws IOException { Constraint.isNotNull(StringSupport.trimOrNull(context), "Context cannot be null or empty"); Constraint.isNotNull(StringSupport.trimOrNull(key), "Key cannot be null or empty"); final String namespace = lookupNamespace(context); if (namespace == null) { logger.debug("Namespace for context {} does not exist", context); return null; } final String cacheKey = memcachedKey(namespace, key); logger.debug("Reading entry at {} for context={}, key={}", cacheKey, context, key); final CASValue<MemcachedStorageRecord> record; try { record = handleAsyncResult(memcacheClient.asyncGets(cacheKey, storageRecordTranscoder)); } catch (RuntimeException e) { throw new IOException("Memcached operation failed", e); } if (record == null) { return null; } record.getValue().setVersion(record.getCas()); return record.getValue(); }
if (CASResponse.OK == response) { final CASValue<MemcachedStorageRecord> newRecord = handleAsyncResult( memcacheClient.asyncGets(cacheKey, storageRecordTranscoder)); if (newRecord != null) { newVersion = newRecord.getCas();