Module io.github.bucket4j.core
Class SkipSyncOnZeroOptimization
java.lang.Object
io.github.bucket4j.distributed.proxy.optimization.skiponzero.SkipSyncOnZeroOptimization
- All Implemented Interfaces:
Optimization
Optimization that can serve requests locally without synchronization with external storage when it detects that there is no tokens in remote storage,
in such case synchronization with storage is being postponed to proposed refill of first token.
This optimization is based on top of
BatchingOptimization, so multiple parallel request to same bucket are grouped.
Usage of this optimization can lead to temporal under-consumption in case of tokens are being added to bucket via API like Bucket.addTokens(long) or Bucket.reset().
- See Also:
-
Field Summary
Fields inherited from interface io.github.bucket4j.distributed.proxy.optimization.Optimization
NONE_OPTIMIZED -
Constructor Summary
ConstructorsConstructorDescriptionSkipSyncOnZeroOptimization(OptimizationListener listener, TimeMeter timeMeter) -
Method Summary
Modifier and TypeMethodDescriptionapply(AsyncCommandExecutor originalExecutor) Decorates command executor in order to apply optimization strategy.apply(CommandExecutor originalExecutor) Decorates command executor in order to apply optimization strategy.withListener(OptimizationListener listener) Specifies the listener for optimization events
-
Constructor Details
-
SkipSyncOnZeroOptimization
-
-
Method Details
-
withListener
Description copied from interface:OptimizationSpecifies the listener for optimization events- Specified by:
withListenerin interfaceOptimization- Parameters:
listener- the listener for optimization events- Returns:
- the new instance of
Optimizationwith configured listener
-
apply
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-
apply
Description copied from interface:OptimizationDecorates command executor in order to apply optimization strategy.- Specified by:
applyin interfaceOptimization- Parameters:
originalExecutor- command executor that need to be optimized- Returns:
- decorated command executor
-