Interface ProxyManager<K>

Type Parameters:
K - type of primary key
All Known Implementing Classes:
AbstractCompareAndSwapBasedProxyManager, AbstractLockBasedProxyManager, AbstractProxyManager, AbstractSelectForUpdateBasedProxyManager, ProxyManagerView

public interface ProxyManager<K>
Represents an extension point of Bucket4j library. ProxyManager provides API for building and managing the collection of BucketProxy in backing storage. Typically, an instance of ProxyManager is organized around RDBMS table, GRID cache, or some similarly isolated part of external storage. Primary keys are used to distinguish persisted state of different buckets.
See Also:
  • Method Details

    • getProxy

      default BucketProxy getProxy(K key, Supplier<BucketConfiguration> configurationSupplier)
      Creates bucket-proxy that configured by default parameters that set on proxy-manager level. In case if you need to configure something special for bucket like implicit config replacement you should to use builder() instead of this method.
      Parameters:
      key - the key that used in external storage to distinguish one bucket from another.
      configurationSupplier - provider for bucket configuration
      Returns:
      new instance of BucketProxy
    • builder

      Creates new instance of RemoteBucketBuilder.

      Use this method only if you need to create bucket with parameters that can not be specified via AbstractProxyManagerBuilder, otherwise prefer getProxy(Object, Supplier)

      Returns:
      new instance of RemoteBucketBuilder
    • getProxyConfiguration

      Optional<BucketConfiguration> getProxyConfiguration(K key)
      Locates configuration of bucket which actually stored in the underlying storage.
      Parameters:
      key - the unique identifier used to point to the bucket in external storage.
      Returns:
      Optional surround the configuration or empty optional if bucket with specified key is not stored.
    • removeProxy

      void removeProxy(K key)
      Removes persisted state of bucket from underlying storage.
      Parameters:
      key - the primary key of bucket which state need to be removed from underlying storage.
    • isAsyncModeSupported

      boolean isAsyncModeSupported()
      Describes whether this manager supports asynchronous API. If this method returns false then any invocation of asAsync() will throw UnsupportedOperationException.
      Returns:
      true if this manager supports asynchronous API
    • isExpireAfterWriteSupported

      default boolean isExpireAfterWriteSupported()
      Describes whether this manager supports expire-after-write feature.
      Returns:
      true if this manager supports expire-after-write feature.
    • asAsync

      Returns asynchronous API for this proxy manager.
      Returns:
      asynchronous API for this proxy manager.
      Throws:
      UnsupportedOperationException - in case of this proxy manager does not support Async API.
    • withMapper

      default <K1> ProxyManager<K1> withMapper(Function<? super K1,? extends K> mapper)
      Returns a proxy object that wraps this ProxyManager such that keys are first mapped using the specified mapping function before being sent to the remote store. The returned ProxyManager shares the same underlying store as the original, and keys that map to the same value will share the same remote state.
      Type Parameters:
      K1 - the type of key accepted by returned ProxyManager
      Parameters:
      mapper - the mapper function to apply to keys
      Returns:
      a proxy object that wraps this ProxyManager