asyncIncr
原子增(减)操作。incr的异步版本。
public static interface IncrListener extends GenericFutureListener<Future<Long>> {
/**
* This function will be called when listened asyncIncr future is done.
*
* @param future the listened future
* @throws Exception throw exception if any error occurs.
*
* Notice: User shouldn't do any operations that may block or time-consuming
*/
@Override
public void operationComplete(Future<Long> future) throws Exception;
}
/**
* atomically increment value by key, async version
*
* @param hashKey the hash key to increment.
* @param sortKey the sort key to increment.
* @param increment the increment to be added to the old value.
* @param timeout how long will the operation timeout in milliseconds.
* if timeout > 0, it is a timeout value for current op,
* else the timeout value in the configuration file will be used.
* @return the future for current op
* <p>
* Future return:
* On success: return new value.
* On failure: a throwable, which is an instance of PException
* <p>
* Thread safety:
* All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
* listeners for the same future are guaranteed to be executed as the same order as the listeners added.
* But listeners for different tables are not guaranteed to be dispatched in the same thread.
*/
public Future<Long> asyncIncr(byte[] hashKey, byte[] sortKey, long increment, int timeout/*ms*/);
注:
- 参数和返回值:参见同步接口incr。