Class PostgreSQLSelectForUpdateBasedProxyManager<K>
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.AbstractProxyManager<K>
-
- io.github.bucket4j.distributed.proxy.generic.select_for_update.AbstractSelectForUpdateBasedProxyManager<K>
-
- io.github.bucket4j.postgresql.PostgreSQLSelectForUpdateBasedProxyManager<K>
-
- Type Parameters:
K- type of primary key
- All Implemented Interfaces:
ProxyManager<K>
public class PostgreSQLSelectForUpdateBasedProxyManager<K> extends AbstractSelectForUpdateBasedProxyManager<K>
- 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<K> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SelectForUpdateBasedTransactionallocateTransaction(K key)voidremoveProxy(K 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.bucket4j.distributed.proxy.ProxyManager
withMapper
-
-
-
-
Constructor Detail
-
PostgreSQLSelectForUpdateBasedProxyManager
public PostgreSQLSelectForUpdateBasedProxyManager(SQLProxyConfiguration<K> configuration)
- Parameters:
configuration-SQLProxyConfigurationconfiguration.
-
-
Method Detail
-
allocateTransaction
protected SelectForUpdateBasedTransaction allocateTransaction(K key)
- Specified by:
allocateTransactionin classAbstractSelectForUpdateBasedProxyManager<K>
-
removeProxy
public void removeProxy(K key)
-
-