Module io.github.bucket4j.core
Interface LockBasedTransaction
-
public interface LockBasedTransactionDescribes the set of operations thatAbstractLockBasedProxyManagertypically performs in reaction to user request. The typical flow is following:- begin -
begin() - lock -
lockAndGet() - update -
update(byte[], RemoteBucketState) - unlock -
unlock() - 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 transactionsvoidcreate(byte[] data, RemoteBucketState state)Creates the data by the key associated with this transaction.byte[]lockAndGet()Locks data by the key associated with this transaction and returns data that is associated with the key.voidrelease()Frees resources associated with this transactionvoidrollback()Rollbacks transaction if underlying storage requires transactionsvoidunlock()Unlocks data by the key associated with this transaction.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
-
lockAndGet
byte[] lockAndGet()
Locks data by the key associated with this transaction and returns data that is associated with the key. There is strong guarantee thatunlock()will be called iflockAndGet()returns successfully.- Returns:
- Returns the data by the key associated with this transaction, or null data associated with key does not exist
-
unlock
void unlock()
Unlocks data by the key associated with this transaction.
-
create
void create(byte[] data, RemoteBucketState state)Creates the data by the key associated with this transaction.- Parameters:
data- bucket state to persistsstate- of bucket - can be used to extract additional data is useful for persistence or logging.
-
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
-
-