asyncIncr

原子增(减)操作。incr的异步版本。

  1. public static interface IncrListener extends GenericFutureListener<Future<Long>> {
  2. /**
  3. * This function will be called when listened asyncIncr future is done.
  4. *
  5. * @param future the listened future
  6. * @throws Exception throw exception if any error occurs.
  7. *
  8. * Notice: User shouldn't do any operations that may block or time-consuming
  9. */
  10. @Override
  11. public void operationComplete(Future<Long> future) throws Exception;
  12. }
  13. /**
  14. * atomically increment value by key, async version
  15. *
  16. * @param hashKey the hash key to increment.
  17. * @param sortKey the sort key to increment.
  18. * @param increment the increment to be added to the old value.
  19. * @param timeout how long will the operation timeout in milliseconds.
  20. * if timeout > 0, it is a timeout value for current op,
  21. * else the timeout value in the configuration file will be used.
  22. * @return the future for current op
  23. * <p>
  24. * Future return:
  25. * On success: return new value.
  26. * On failure: a throwable, which is an instance of PException
  27. * <p>
  28. * Thread safety:
  29. * All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
  30. * listeners for the same future are guaranteed to be executed as the same order as the listeners added.
  31. * But listeners for different tables are not guaranteed to be dispatched in the same thread.
  32. */
  33. public Future<Long> asyncIncr(byte[] hashKey, byte[] sortKey, long increment, int timeout/*ms*/);

注:

  • 参数和返回值:参见同步接口incr