Module io.github.bucket4j.caffeine
Package io.github.bucket4j.caffeine
Class CaffeineProxyManager<K>
- java.lang.Object
-
- io.github.bucket4j.distributed.proxy.AbstractProxyManager<K>
-
- io.github.bucket4j.caffeine.CaffeineProxyManager<K>
-
- All Implemented Interfaces:
ProxyManager<K>
public class CaffeineProxyManager<K> extends AbstractProxyManager<K>
The extension of Bucket4j library addressed to support Caffeine caching library.
-
-
Constructor Summary
Constructors Constructor Description CaffeineProxyManager(com.github.benmanes.caffeine.cache.Caffeine<? super K,? super RemoteBucketState> builder, Duration keepAfterRefillDuration)Creates new instance ofCaffeineProxyManagerCaffeineProxyManager(com.github.benmanes.caffeine.cache.Caffeine<? super K,? super RemoteBucketState> builder, Duration keepAfterRefillDuration, ClientSideConfig clientSideConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> CommandResult<T>execute(K key, Request<T> request)<T> CompletableFuture<CommandResult<T>>executeAsync(K key, Request<T> request)com.github.benmanes.caffeine.cache.Cache<K,RemoteBucketState>getCache()Returns the cache that is used for storing the bucketsbooleanisAsyncModeSupported()protected CompletableFuture<Void>removeAsync(K key)voidremoveProxy(K key)-
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
-
CaffeineProxyManager
public CaffeineProxyManager(com.github.benmanes.caffeine.cache.Caffeine<? super K,? super RemoteBucketState> builder, Duration keepAfterRefillDuration)
Creates new instance ofCaffeineProxyManager- Parameters:
builder- the builder that will be used for cache creationkeepAfterRefillDuration- specifies how long bucket should be held in the cache after all consumed tokens have been refilled.
-
CaffeineProxyManager
public CaffeineProxyManager(com.github.benmanes.caffeine.cache.Caffeine<? super K,? super RemoteBucketState> builder, Duration keepAfterRefillDuration, ClientSideConfig clientSideConfig)
-
-
Method Detail
-
getCache
public com.github.benmanes.caffeine.cache.Cache<K,RemoteBucketState> getCache()
Returns the cache that is used for storing the buckets- Returns:
- the cache that is used for storing the buckets
-
execute
public <T> CommandResult<T> execute(K key, Request<T> request)
- Specified by:
executein classAbstractProxyManager<K>
-
isAsyncModeSupported
public boolean isAsyncModeSupported()
-
executeAsync
public <T> CompletableFuture<CommandResult<T>> executeAsync(K key, Request<T> request)
- Specified by:
executeAsyncin classAbstractProxyManager<K>
-
removeProxy
public void removeProxy(K key)
-
removeAsync
protected CompletableFuture<Void> removeAsync(K key)
- Specified by:
removeAsyncin classAbstractProxyManager<K>
-
-