Module io.github.bucket4j.core
Interface SelectForUpdateBasedTransaction
-
public interface SelectForUpdateBasedTransactionDescribes the set of operations thatAbstractSelectForUpdateBasedProxyManagertypically performs in reaction to user request. The typical flow is following:- begin -
begin() - lock -
tryLockAndGet() - update -
update(byte[], RemoteBucketState) - commit -
commit() - release -
release()
- begin -
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbegin()Begins transaction if underlying storage requires transactions.voidcommit()Commits transaction if underlying storage requires transactionsvoidrelease()Frees resources associated with this transactionvoidrollback()Rollbacks transaction if underlying storage requires transactionsbooleantryInsertEmptyData()Creates empty data by for the key associated with this transaction.LockAndGetResulttryLockAndGet()Locks data by the key associated with this transaction and returns data that is associated with the key.voidupdate(byte[] data, RemoteBucketState newState)Updates the data by the key associated with this transaction.
-
-
-
Method Detail
-
begin
void begin()
Begins transaction if underlying storage requires transactions. There is strong guarantee thatcommit()orrollback()will be called ifbegin()returns successfully.
-
rollback
void rollback()
Rollbacks transaction if underlying storage requires transactions
-
commit
void commit()
Commits transaction if underlying storage requires transactions
-
tryLockAndGet
LockAndGetResult tryLockAndGet()
Locks data by the key associated with this transaction and returns data that is associated with the key.- Returns:
- the data by the key associated with this transaction, or null data associated with key does not exist
-
tryInsertEmptyData
boolean tryInsertEmptyData()
Creates empty data by for the key associated with this transaction. This operation is required to be able to lock data in the scope of next transaction.- Returns:
- true if data has been inserted
-
update
void update(byte[] data, RemoteBucketState newState)Updates the data by the key associated with this transaction.- Parameters:
data- bucket state to persistsnewState- new state of bucket - can be used to extract additional data is useful for persistence or logging.
-
release
void release()
Frees resources associated with this transaction
-
-