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

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

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

MemcachedClient.asyncCAS介绍

[英]Asynchronous CAS operation using the default transcoder with expiration.
[中]异步CAS操作,使用过期的默认转码器。

代码示例

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

  1. @Override
  2. protected Cancellable updateCAS(
  3. final String storageKey, final CASValue<Object> casValue, final byte[] storageObject, final FutureCallback<Boolean> callback) {
  4. return operation(client.asyncCAS(storageKey, casValue.getCas(), storageObject), new FutureCallback<CASResponse>() {
  5. @Override
  6. public void completed(final CASResponse result) {
  7. callback.completed(result == CASResponse.OK);
  8. }
  9. @Override
  10. public void failed(final Exception ex) {
  11. callback.failed(ex);
  12. }
  13. @Override
  14. public void cancelled() {
  15. callback.cancelled();
  16. }
  17. });
  18. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue is too
  9. * full to accept any more requests
  10. */
  11. public Future<CASResponse> asyncCAS(String key, long casId, Object value) {
  12. return asyncCAS(key, casId, value, transcoder);
  13. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue
  9. * is too full to accept any more requests
  10. */
  11. public Future<CASResponse> asyncCAS(String key, long casId, Object value) {
  12. return asyncCAS(key, casId, value, transcoder);
  13. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue
  9. * is too full to accept any more requests
  10. */
  11. public Future<CASResponse> asyncCAS(String key, long casId, Object value) {
  12. return asyncCAS(key, casId, value, transcoder);
  13. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue
  9. * is too full to accept any more requests
  10. */
  11. public Future<CASResponse> asyncCAS(String key, long casId, Object value) {
  12. return asyncCAS(key, casId, value, transcoder);
  13. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue is too
  9. * full to accept any more requests
  10. */
  11. @Override
  12. public OperationFuture<CASResponse>
  13. asyncCAS(String key, long casId, Object value) {
  14. return asyncCAS(key, casId, value, transcoder);
  15. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a future that will indicate the status of the CAS
  10. * @throws IllegalStateException in the rare circumstance where queue
  11. * is too full to accept any more requests
  12. */
  13. public <T> Future<CASResponse> asyncCAS(String key, long casId, T value,
  14. Transcoder<T> tc) {
  15. return asyncCAS(key, casId, 0, value, tc);
  16. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @return a future that will indicate the status of the CAS
  8. * @throws IllegalStateException in the rare circumstance where queue is too
  9. * full to accept any more requests
  10. */
  11. @Override
  12. public OperationFuture<CASResponse>
  13. asyncCAS(String key, long casId, Object value) {
  14. return asyncCAS(key, casId, value, transcoder);
  15. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder with expiration.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param exp the expiration of this object
  7. * @param value the new value
  8. * @return a future that will indicate the status of the CAS
  9. * @throws IllegalStateException in the rare circumstance where queue is too
  10. * full to accept any more requests
  11. */
  12. @Override
  13. public OperationFuture<CASResponse>
  14. asyncCAS(String key, long casId, int exp, Object value) {
  15. return asyncCAS(key, casId, exp, value, transcoder);
  16. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param value the new value
  7. * @param tc the transcoder to serialize and unserialize the value
  8. * @return a future that will indicate the status of the CAS
  9. * @throws IllegalStateException in the rare circumstance where queue
  10. * is too full to accept any more requests
  11. */
  12. public <T> Future<CASResponse> asyncCAS(String key, long casId, T value,
  13. Transcoder<T> tc) {
  14. return asyncCAS(key, casId, 0, value, tc);
  15. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder with expiration.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param exp the expiration of this object
  7. * @param value the new value
  8. * @return a future that will indicate the status of the CAS
  9. * @throws IllegalStateException in the rare circumstance where queue is too
  10. * full to accept any more requests
  11. */
  12. @Override
  13. public OperationFuture<CASResponse>
  14. asyncCAS(String key, long casId, int exp, Object value) {
  15. return asyncCAS(key, casId, exp, value, transcoder);
  16. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a future that will indicate the status of the CAS
  10. * @throws IllegalStateException in the rare circumstance where queue is too
  11. * full to accept any more requests
  12. */
  13. @Override
  14. public <T> OperationFuture<CASResponse>
  15. asyncCAS(String key, long casId, T value, Transcoder<T> tc) {
  16. return asyncCAS(key, casId, 0, value, tc);
  17. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a future that will indicate the status of the CAS
  10. * @throws IllegalStateException in the rare circumstance where queue is too
  11. * full to accept any more requests
  12. */
  13. @Override
  14. public <T> OperationFuture<CASResponse>
  15. asyncCAS(String key, long casId, T value, Transcoder<T> tc) {
  16. return asyncCAS(key, casId, 0, value, tc);
  17. }

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

  1. /**
  2. * Asynchronous CAS operation using the default transcoder with expiration.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param exp the expiration of this object
  7. * @param value the new value
  8. * @return a future that will indicate the status of the CAS
  9. * @throws IllegalStateException in the rare circumstance where queue is too
  10. * full to accept any more requests
  11. */
  12. public Future<CASResponse> asyncCAS(String key, long casId,
  13. int exp, Object value) {
  14. return asyncCAS(key, casId, exp, value, transcoder);
  15. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a future that will indicate the status of the CAS
  10. * @throws IllegalStateException in the rare circumstance where queue is too
  11. * full to accept any more requests
  12. */
  13. public <T> Future<CASResponse> asyncCAS(String key, long casId, T value,
  14. Transcoder<T> tc) {
  15. return asyncCAS(key, casId, 0, value, tc);
  16. }

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

  1. /**
  2. * Asynchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a future that will indicate the status of the CAS
  10. * @throws IllegalStateException in the rare circumstance where queue
  11. * is too full to accept any more requests
  12. */
  13. public <T> Future<CASResponse> asyncCAS(String key, long casId, T value,
  14. Transcoder<T> tc) {
  15. return asyncCAS(key, casId, 0, value, tc);
  16. }

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

  1. /**
  2. * Perform a synchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param exp the expiration of this object
  8. * @param value the new value
  9. * @param tc the transcoder to serialize and unserialize the value
  10. * @return a CASResponse
  11. * @throws OperationTimeoutException if global operation timeout is
  12. * exceeded
  13. * @throws IllegalStateException in the rare circumstance where queue
  14. * is too full to accept any more requests
  15. */
  16. public <T> CASResponse cas(String key, long casId, int exp, T value,
  17. Transcoder<T> tc) {
  18. try {
  19. return asyncCAS(key, casId, exp, value, tc).get(operationTimeout,
  20. TimeUnit.MILLISECONDS);
  21. } catch (InterruptedException e) {
  22. throw new RuntimeException("Interrupted waiting for value", e);
  23. } catch (ExecutionException e) {
  24. throw new RuntimeException("Exception waiting for value", e);
  25. } catch (TimeoutException e) {
  26. throw new OperationTimeoutException("Timeout waiting for value", e);
  27. }
  28. }

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

  1. /**
  2. * Perform a synchronous CAS operation.
  3. *
  4. * @param <T>
  5. * @param key the key
  6. * @param casId the CAS identifier (from a gets operation)
  7. * @param exp the expiration of this object
  8. * @param value the new value
  9. * @param tc the transcoder to serialize and unserialize the value
  10. * @return a CASResponse
  11. * @throws OperationTimeoutException if global operation timeout is exceeded
  12. * @throws IllegalStateException in the rare circumstance where queue is too
  13. * full to accept any more requests
  14. */
  15. public <T> CASResponse cas(String key, long casId, int exp, T value,
  16. Transcoder<T> tc) {
  17. try {
  18. return asyncCAS(key, casId, exp, value, tc).get(operationTimeout,
  19. TimeUnit.MILLISECONDS);
  20. } catch (InterruptedException e) {
  21. throw new RuntimeException("Interrupted waiting for value", e);
  22. } catch (ExecutionException e) {
  23. throw new RuntimeException("Exception waiting for value", e);
  24. } catch (TimeoutException e) {
  25. throw new OperationTimeoutException("Timeout waiting for value", e);
  26. }
  27. }

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

  1. /**
  2. * Perform a synchronous CAS operation.
  3. *
  4. * @param key the key
  5. * @param casId the CAS identifier (from a gets operation)
  6. * @param exp the expiration of this object
  7. * @param value the new value
  8. * @param tc the transcoder to serialize and unserialize the value
  9. * @return a CASResponse
  10. * @throws OperationTimeoutException if global operation timeout is
  11. * exceeded
  12. * @throws IllegalStateException in the rare circumstance where queue
  13. * is too full to accept any more requests
  14. */
  15. public <T> CASResponse cas(String key, long casId, int exp, T value,
  16. Transcoder<T> tc) {
  17. try {
  18. return asyncCAS(key, casId, exp, value, tc).get(operationTimeout,
  19. TimeUnit.MILLISECONDS);
  20. } catch (InterruptedException e) {
  21. throw new RuntimeException("Interrupted waiting for value", e);
  22. } catch (ExecutionException e) {
  23. throw new RuntimeException("Exception waiting for value", e);
  24. } catch (TimeoutException e) {
  25. throw new OperationTimeoutException("Timeout waiting for value", e);
  26. }
  27. }

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

  1. @Override
  2. protected Cancellable updateCAS(
  3. final String storageKey, final CASValue<Object> casValue, final byte[] storageObject, final FutureCallback<Boolean> callback) {
  4. return operation(client.asyncCAS(storageKey, casValue.getCas(), storageObject), new FutureCallback<CASResponse>() {
  5. @Override
  6. public void completed(final CASResponse result) {
  7. callback.completed(result == CASResponse.OK);
  8. }
  9. @Override
  10. public void failed(final Exception ex) {
  11. callback.failed(ex);
  12. }
  13. @Override
  14. public void cancelled() {
  15. callback.cancelled();
  16. }
  17. });
  18. }

相关文章