Class PostgreSQLSelectForUpdateBasedProxyManager
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.AbstractProxyManager<K>
-
- io.github.bucket4j.distributed.proxy.generic.select_for_update.AbstractSelectForUpdateBasedProxyManager<Long>
-
- io.github.bucket4j.postgresql.PostgreSQLSelectForUpdateBasedProxyManager
-
- All Implemented Interfaces:
ProxyManager<Long>
public class PostgreSQLSelectForUpdateBasedProxyManager extends AbstractSelectForUpdateBasedProxyManager<Long>
- Author:
- Maxim Bartkov
The extension of Bucket4j library addressed to support PostgreSQL
To start work with the PostgreSQL extension you must create a table, which will include the possibility to work with buckets
In order to do this, your table should include the next columns: id as a PRIMARY KEY (BIGINT) and state (BYTEA)
To define column names,
SQLProxyConfigurationincludeBucketTableSettingswhich takes settings for the table to work with Bucket4j.This implementation solves transaction related problems via Based on SELECT FOR UPDATE SQL syntax. This prevents them from being modified or deleted by other transactions until the current transaction ends. That is, other transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these rows will be blocked until the current transaction ends. Also, if an UPDATE, DELETE, or SELECT FOR UPDATE from another transaction has already locked a selected row or rows, SELECT FOR UPDATE will wait for the other transaction to complete, and will then lock and return the updated row (or no row, if the row was deleted). Within a SERIALIZABLE transaction, however, an error will be thrown if a row to be locked has changed since the transaction started.
-
-
Constructor Summary
Constructors Constructor Description PostgreSQLSelectForUpdateBasedProxyManager(SQLProxyConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SelectForUpdateBasedTransactionallocateTransaction(Long key)voidremoveProxy(Long key)-
Methods inherited from class io.github.bucket4j.distributed.proxy.generic.select_for_update.AbstractSelectForUpdateBasedProxyManager
execute, executeAsync, isAsyncModeSupported, removeAsync
-
Methods inherited from class io.github.bucket4j.distributed.proxy.AbstractProxyManager
asAsync, builder, getBackwardCompatibilityVersion, getClientSideConfig, getClientSideTime, getProxyConfiguration
-
-
-
-
Constructor Detail
-
PostgreSQLSelectForUpdateBasedProxyManager
public PostgreSQLSelectForUpdateBasedProxyManager(SQLProxyConfiguration configuration)
- Parameters:
configuration-SQLProxyConfigurationconfiguration.
-
-
Method Detail
-
allocateTransaction
protected SelectForUpdateBasedTransaction allocateTransaction(Long key)
- Specified by:
allocateTransactionin classAbstractSelectForUpdateBasedProxyManager<Long>
-
removeProxy
public void removeProxy(Long key)
-
-