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

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

本文整理了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

@Override
protected Cancellable updateCAS(
    final String storageKey, final CASValue<Object> casValue, final byte[] storageObject, final FutureCallback<Boolean> callback) {
  return operation(client.asyncCAS(storageKey, casValue.getCas(), storageObject), new FutureCallback<CASResponse>() {
    @Override
    public void completed(final CASResponse result) {
      callback.completed(result == CASResponse.OK);
    }
    @Override
    public void failed(final Exception ex) {
      callback.failed(ex);
    }
    @Override
    public void cancelled() {
      callback.cancelled();
    }
  });
}

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

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

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

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

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

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

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

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

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

/**
 * Asynchronous CAS operation using the default transcoder.
 *
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param value the new value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public OperationFuture<CASResponse>
asyncCAS(String key, long casId, Object value) {
 return asyncCAS(key, casId, value, transcoder);
}

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

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

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

/**
 * Asynchronous CAS operation using the default transcoder.
 *
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param value the new value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public OperationFuture<CASResponse>
asyncCAS(String key, long casId, Object value) {
 return asyncCAS(key, casId, value, transcoder);
}

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

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

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

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

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

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

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

/**
 * Asynchronous CAS operation.
 *
 * @param <T>
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public <T> OperationFuture<CASResponse>
asyncCAS(String key, long casId, T value, Transcoder<T> tc) {
 return asyncCAS(key, casId, 0, value, tc);
}

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

/**
 * Asynchronous CAS operation.
 *
 * @param <T>
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
@Override
public <T> OperationFuture<CASResponse>
asyncCAS(String key, long casId, T value, Transcoder<T> tc) {
 return asyncCAS(key, casId, 0, value, tc);
}

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

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

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

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

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

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

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

/**
 * Perform a synchronous CAS operation.
 *
 * @param <T>
 * @param key   the key
 * @param casId the CAS identifier (from a gets operation)
 * @param exp   the expiration of this object
 * @param value the new value
 * @param tc    the transcoder to serialize and unserialize the value
 * @return a CASResponse
 * @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> CASResponse cas(String key, long casId, int exp, T value,
              Transcoder<T> tc) {
 try {
  return asyncCAS(key, casId, exp, value, 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);
 }
}

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

/**
 * Perform a synchronous CAS operation.
 *
 * @param <T>
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param exp the expiration of this object
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a CASResponse
 * @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> CASResponse cas(String key, long casId, int exp, T value,
  Transcoder<T> tc) {
 try {
  return asyncCAS(key, casId, exp, value, 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);
 }
}

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

/**
 * Perform a synchronous CAS operation.
 *
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param exp the expiration of this object
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a CASResponse
 * @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> CASResponse cas(String key, long casId, int exp, T value,
    Transcoder<T> tc) {
  try {
    return asyncCAS(key, casId, exp, value, 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);
  }
}

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

@Override
protected Cancellable updateCAS(
    final String storageKey, final CASValue<Object> casValue, final byte[] storageObject, final FutureCallback<Boolean> callback) {
  return operation(client.asyncCAS(storageKey, casValue.getCas(), storageObject), new FutureCallback<CASResponse>() {
    @Override
    public void completed(final CASResponse result) {
      callback.completed(result == CASResponse.OK);
    }
    @Override
    public void failed(final Exception ex) {
      callback.failed(ex);
    }
    @Override
    public void cancelled() {
      callback.cancelled();
    }
  });
}

相关文章