default CompletableFuture<Long> incrementAndGet(K key, long amount) { return increment(key, amount, Options.incrementAndGet()) .thenApply(result -> { try { return result.totalAmount(); } finally { result.close(); } }); }
default CompletableFuture<Long> getAndIncrement(K pKey, K lKey, long amount) { return increment(pKey, lKey, amount, Options.incrementAndGet()) .thenApply(result -> { try { return result.totalAmount() - amount; } finally { result.close(); } }); }
default CompletableFuture<Long> getAndIncrement(K key, long amount) { return increment(key, amount, Options.incrementAndGet()) .thenApply(result -> { try { return result.totalAmount() - amount; } finally { result.close(); } }); }
default CompletableFuture<Long> incrementAndGet(K pKey, K lKey, long amount) { return increment(pKey, lKey, amount, Options.incrementAndGet()) .thenApply(result -> { try { return result.totalAmount(); } finally { result.close(); } }); }
@Override default CompletableFuture<Long> incrementAndGet(K k, long amount) { IncrementOp<K, V> op = getOpFactory().newIncrement( k, amount, Options.incrementAndGet()); return increment(op).thenCompose(result -> { try { Code code = result.code(); if (Code.OK == code) { return FutureUtils.value(result.totalAmount()); } else { return failWithCode(code, "Failed to increment(" + k + ", " + amount + ") to store " + name()); } } finally { result.close(); } }); }
@Override default CompletableFuture<Long> getAndIncrement(K k, long amount) { IncrementOp<K, V> op = getOpFactory().newIncrement( k, amount, Options.incrementAndGet()); return increment(op).thenCompose(result -> { try { Code code = result.code(); if (Code.OK == code) { return FutureUtils.value(result.totalAmount() - amount); } else { return failWithCode(code, "Failed to increment(" + k + ", " + amount + ") to store " + name()); } } finally { result.close(); } }); } }