Package io.github.bucket4j.postgresql
Class PostgreSQLadvisoryLockBasedProxyManager
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.AbstractProxyManager<K>
-
- io.github.bucket4j.distributed.proxy.generic.pessimistic_locking.AbstractLockBasedProxyManager<Long>
-
- io.github.bucket4j.postgresql.PostgreSQLadvisoryLockBasedProxyManager
-
- All Implemented Interfaces:
ProxyManager<Long>
public class PostgreSQLadvisoryLockBasedProxyManager extends AbstractLockBasedProxyManager<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 pg_advisory_xact_lock locks an application-defined resource, which can be identified either by a single 64-bit key value or two 32-bit key values (note that these two key spaces do not overlap). If another session already holds a lock on the same resource identifier, this function will wait until the resource becomes available. The lock is exclusive. Multiple lock requests stack so that if the same resource is locked three times it must then be unlocked three times to be released for other sessions use. The lock is automatically released at the end of the current transaction and cannot be released explicitly.
-
-
Constructor Summary
Constructors Constructor Description PostgreSQLadvisoryLockBasedProxyManager(SQLProxyConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LockBasedTransactionallocateTransaction(Long key)voidremoveProxy(Long key)-
Methods inherited from class io.github.bucket4j.distributed.proxy.generic.pessimistic_locking.AbstractLockBasedProxyManager
execute, executeAsync, isAsyncModeSupported, removeAsync
-
Methods inherited from class io.github.bucket4j.distributed.proxy.AbstractProxyManager
asAsync, builder, getBackwardCompatibilityVersion, getClientSideConfig, getClientSideTime, getProxyConfiguration
-
-
-
-
Constructor Detail
-
PostgreSQLadvisoryLockBasedProxyManager
public PostgreSQLadvisoryLockBasedProxyManager(SQLProxyConfiguration configuration)
- Parameters:
configuration-SQLProxyConfigurationconfiguration.
-
-
Method Detail
-
allocateTransaction
protected LockBasedTransaction allocateTransaction(Long key)
- Specified by:
allocateTransactionin classAbstractLockBasedProxyManager<Long>
-
removeProxy
public void removeProxy(Long key)
-
-