Package io.github.bucket4j.postgresql
Class PostgreSQLadvisoryLockBasedProxyManager<K>
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.AbstractProxyManager<K>
-
- io.github.bucket4j.distributed.proxy.generic.pessimistic_locking.AbstractLockBasedProxyManager<K>
-
- io.github.bucket4j.postgresql.PostgreSQLadvisoryLockBasedProxyManager<K>
-
- Type Parameters:
K- type of primary key
- All Implemented Interfaces:
ProxyManager<K>
public class PostgreSQLadvisoryLockBasedProxyManager<K> extends AbstractLockBasedProxyManager<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 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<K> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LockBasedTransactionallocateTransaction(K key)voidremoveProxy(K 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
-
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
-
PostgreSQLadvisoryLockBasedProxyManager
public PostgreSQLadvisoryLockBasedProxyManager(SQLProxyConfiguration<K> configuration)
- Parameters:
configuration-SQLProxyConfigurationconfiguration.
-
-
Method Detail
-
allocateTransaction
protected LockBasedTransaction allocateTransaction(K key)
- Specified by:
allocateTransactionin classAbstractLockBasedProxyManager<K>
-
removeProxy
public void removeProxy(K key)
-
-