Module io.github.bucket4j.core
Interface AsyncCompareAndSwapOperation
-
public interface AsyncCompareAndSwapOperationDescribes the set of operations thatAbstractCompareAndSwapBasedProxyManagertypically performs in reaction to user request. The typical flow is following:- getStateData -
getStateData() - compareAndSwap -
#compareAndSwap(byte[], byte[]) - Return to first step if CAS was unsuccessful
- getStateData -
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableFuture<Boolean>compareAndSwap(byte[] originalData, byte[] newData, RemoteBucketState newState)Compares and swap data associated with keyCompletableFuture<Optional<byte[]>>getStateData()Reads data if it exists
-
-
-
Method Detail
-
getStateData
CompletableFuture<Optional<byte[]>> getStateData()
Reads data if it exists- Returns:
- persisted data or empty optional if data not exists
-
compareAndSwap
CompletableFuture<Boolean> compareAndSwap(byte[] originalData, byte[] newData, RemoteBucketState newState)
Compares and swap data associated with key- Parameters:
originalData- previous bucket state(can be null).newData- new bucket statenewState- new state of bucket - can be used to extract additional data is useful for persistence or logging.- Returns:
trueif data changed,falseif another parallel transaction achieved success instead of current transaction
-
-