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

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

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

MemcachedClient.asyncGets介绍

[英]Gets (with CAS support) the given key asynchronously and decode using the default transcoder.
[中]异步获取(支持CAS)给定密钥,并使用默认转码器进行解码。

代码示例

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

  1. @Override
  2. protected Cancellable getForUpdateCAS(final String storageKey, final FutureCallback<CASValue<Object>> callback) {
  3. return operation(client.asyncGets(storageKey), callback);
  4. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using the
  3. * default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue is too
  8. * full to accept any more requests
  9. */
  10. public OperationFuture<CASValue<Object>> asyncGets(final String key) {
  11. return asyncGets(key, transcoder);
  12. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using
  3. * the default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue
  8. * is too full to accept any more requests
  9. */
  10. public Future<CASValue<Object>> asyncGets(final String key) {
  11. return asyncGets(key, transcoder);
  12. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using
  3. * the default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue
  8. * is too full to accept any more requests
  9. */
  10. public Future<CASValue<Object>> asyncGets(final String key) {
  11. return asyncGets(key, transcoder);
  12. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using the
  3. * default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue is too
  8. * full to accept any more requests
  9. */
  10. @Override
  11. public OperationFuture<CASValue<Object>> asyncGets(final String key) {
  12. return asyncGets(key, transcoder);
  13. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using the
  3. * default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue is too
  8. * full to accept any more requests
  9. */
  10. @Override
  11. public OperationFuture<CASValue<Object>> asyncGets(final String key) {
  12. return asyncGets(key, transcoder);
  13. }

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

  1. /**
  2. * Gets (with CAS support) the given key asynchronously and decode using
  3. * the default transcoder.
  4. *
  5. * @param key the key to fetch
  6. * @return a future that will hold the return value of the fetch
  7. * @throws IllegalStateException in the rare circumstance where queue
  8. * is too full to accept any more requests
  9. */
  10. public Future<CASValue<Object>> asyncGets(final String key) {
  11. return asyncGets(key, transcoder);
  12. }

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

  1. @Override
  2. protected Cancellable getForUpdateCAS(final String storageKey, final FutureCallback<CASValue<Object>> callback) {
  3. return operation(client.asyncGets(storageKey), callback);
  4. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param key the key to get
  5. * @param tc the transcoder to serialize and unserialize value
  6. * @return the result from the cache and CAS id (null if there is none)
  7. * @throws OperationTimeoutException if 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> CASValue<T> gets(String key, Transcoder<T> tc) {
  13. try {
  14. return asyncGets(key, tc).get(
  15. operationTimeout, TimeUnit.MILLISECONDS);
  16. } catch (InterruptedException e) {
  17. throw new RuntimeException("Interrupted waiting for value", e);
  18. } catch (ExecutionException e) {
  19. throw new RuntimeException("Exception waiting for value", e);
  20. } catch (TimeoutException e) {
  21. throw new OperationTimeoutException("Timeout waiting for value", e);
  22. }
  23. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param <T>
  5. * @param key the key to get
  6. * @param tc the transcoder to serialize and unserialize value
  7. * @return the result from the cache and CAS id (null if there is none)
  8. * @throws OperationTimeoutException if global operation timeout is
  9. * exceeded
  10. * @throws IllegalStateException in the rare circumstance where queue
  11. * is too full to accept any more requests
  12. */
  13. public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
  14. try {
  15. return asyncGets(key, tc).get(
  16. operationTimeout, TimeUnit.MILLISECONDS);
  17. } catch (InterruptedException e) {
  18. throw new RuntimeException("Interrupted waiting for value", e);
  19. } catch (ExecutionException e) {
  20. throw new RuntimeException("Exception waiting for value", e);
  21. } catch (TimeoutException e) {
  22. throw new OperationTimeoutException("Timeout waiting for value", e);
  23. }
  24. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param <T>
  5. * @param key the key to get
  6. * @param tc the transcoder to serialize and unserialize value
  7. * @return the result from the cache and CAS id (null if there is none)
  8. * @throws OperationTimeoutException if global operation timeout is
  9. * exceeded
  10. * @throws IllegalStateException in the rare circumstance where queue
  11. * is too full to accept any more requests
  12. */
  13. public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
  14. try {
  15. return asyncGets(key, tc).get(
  16. operationTimeout, TimeUnit.MILLISECONDS);
  17. } catch (InterruptedException e) {
  18. throw new RuntimeException("Interrupted waiting for value", e);
  19. } catch (ExecutionException e) {
  20. throw new RuntimeException("Exception waiting for value", e);
  21. } catch (TimeoutException e) {
  22. throw new OperationTimeoutException("Timeout waiting for value", e);
  23. }
  24. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param <T>
  5. * @param key the key to get
  6. * @param tc the transcoder to serialize and unserialize value
  7. * @return the result from the cache and CAS id (null if there is none)
  8. * @throws OperationTimeoutException if global operation timeout is exceeded
  9. * @throws IllegalStateException in the rare circumstance where queue is too
  10. * full to accept any more requests
  11. */
  12. public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
  13. try {
  14. return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS);
  15. } catch (InterruptedException e) {
  16. throw new RuntimeException("Interrupted waiting for value", e);
  17. } catch (ExecutionException e) {
  18. throw new RuntimeException("Exception waiting for value", e);
  19. } catch (TimeoutException e) {
  20. throw new OperationTimeoutException("Timeout waiting for value", e);
  21. }
  22. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param <T>
  5. * @param key the key to get
  6. * @param tc the transcoder to serialize and unserialize value
  7. * @return the result from the cache and CAS id (null if there is none)
  8. * @throws OperationTimeoutException if global operation timeout is exceeded
  9. * @throws CancellationException if operation was canceled
  10. * @throws IllegalStateException in the rare circumstance where queue is too
  11. * full to accept any more requests
  12. */
  13. @Override
  14. public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
  15. try {
  16. return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS);
  17. } catch (InterruptedException e) {
  18. throw new RuntimeException("Interrupted waiting for value", e);
  19. } catch (ExecutionException e) {
  20. if(e.getCause() instanceof CancellationException) {
  21. throw (CancellationException) e.getCause();
  22. } else {
  23. throw new RuntimeException("Exception waiting for value", e);
  24. }
  25. } catch (TimeoutException e) {
  26. throw new OperationTimeoutException("Timeout waiting for value", e);
  27. }
  28. }

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

  1. /**
  2. * Gets (with CAS support) with a single key.
  3. *
  4. * @param <T>
  5. * @param key the key to get
  6. * @param tc the transcoder to serialize and unserialize value
  7. * @return the result from the cache and CAS id (null if there is none)
  8. * @throws OperationTimeoutException if global operation timeout is exceeded
  9. * @throws CancellationException if operation was canceled
  10. * @throws IllegalStateException in the rare circumstance where queue is too
  11. * full to accept any more requests
  12. */
  13. @Override
  14. public <T> CASValue<T> gets(String key, Transcoder<T> tc) {
  15. try {
  16. return asyncGets(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS);
  17. } catch (InterruptedException e) {
  18. throw new RuntimeException("Interrupted waiting for value", e);
  19. } catch (ExecutionException e) {
  20. if(e.getCause() instanceof CancellationException) {
  21. throw (CancellationException) e.getCause();
  22. } else {
  23. throw new RuntimeException("Exception waiting for value", e);
  24. }
  25. } catch (TimeoutException e) {
  26. throw new OperationTimeoutException("Timeout waiting for value", e);
  27. }
  28. }

代码示例来源:origin: org.opensaml/opensaml-storage-impl

  1. /**
  2. * Looks up the namespace for the given context name in the cache.
  3. *
  4. * @param context Context name.
  5. *
  6. * @return Corresponding namespace for given context or null if no namespace exists for context.
  7. *
  8. * @throws java.io.IOException On memcached operation errors.
  9. */
  10. protected String lookupNamespace(final String context) throws IOException {
  11. try {
  12. final CASValue<String> result = handleAsyncResult(
  13. memcacheClient.asyncGets(memcachedKey(context), stringTranscoder));
  14. return result == null ? null : result.getValue();
  15. } catch (RuntimeException e) {
  16. throw new IOException("Memcached operation failed", e);
  17. }
  18. }

代码示例来源:origin: org.opensaml/opensaml-storage-impl

  1. memcacheClient.asyncGets(namespace + CTX_KEY_LIST_SUFFIX, stringTranscoder));
  2. if (keys == null) {
  3. logger.debug("No context keys found to update expiration");
  4. memcacheClient.asyncGets(namespace + CTX_KEY_BLACKLIST_SUFFIX, stringTranscoder));
  5. if (blacklistKeys != null) {
  6. keySet.removeAll(Arrays.asList(blacklistKeys.getValue().split(CTX_KEY_LIST_DELIMITER)));

代码示例来源:origin: org.opensaml/opensaml-storage-impl

  1. /** {@inheritDoc} */
  2. @Override
  3. public StorageRecord read(@Nonnull @NotEmpty final String context,
  4. @Nonnull @NotEmpty final String key) throws IOException {
  5. Constraint.isNotNull(StringSupport.trimOrNull(context), "Context cannot be null or empty");
  6. Constraint.isNotNull(StringSupport.trimOrNull(key), "Key cannot be null or empty");
  7. final String namespace = lookupNamespace(context);
  8. if (namespace == null) {
  9. logger.debug("Namespace for context {} does not exist", context);
  10. return null;
  11. }
  12. final String cacheKey = memcachedKey(namespace, key);
  13. logger.debug("Reading entry at {} for context={}, key={}", cacheKey, context, key);
  14. final CASValue<MemcachedStorageRecord> record;
  15. try {
  16. record = handleAsyncResult(memcacheClient.asyncGets(cacheKey, storageRecordTranscoder));
  17. } catch (RuntimeException e) {
  18. throw new IOException("Memcached operation failed", e);
  19. }
  20. if (record == null) {
  21. return null;
  22. }
  23. record.getValue().setVersion(record.getCas());
  24. return record.getValue();
  25. }

代码示例来源:origin: org.mybatis.caches/mybatis-memcached

  1. Future<CASValue<Object>> future;
  2. if (configuration.isCompressionEnabled()) {
  3. future = client.asyncGets(keyString, new CompressorTranscoder());
  4. } else {
  5. future = client.asyncGets(keyString);

代码示例来源:origin: org.opensaml/opensaml-storage-impl

  1. if (CASResponse.OK == response) {
  2. final CASValue<MemcachedStorageRecord> newRecord = handleAsyncResult(
  3. memcacheClient.asyncGets(cacheKey, storageRecordTranscoder));
  4. if (newRecord != null) {
  5. newVersion = newRecord.getCas();

相关文章