java.lang.Object
io.github.bucket4j.distributed.proxy.optimization.skiponzero.SkipSyncOnZeroOptimization
All Implemented Interfaces:
Optimization

public class SkipSyncOnZeroOptimization extends Object implements 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:
  • Constructor Details

  • Method Details

    • withListener

      public Optimization withListener(OptimizationListener listener)
      Description copied from interface: Optimization
      Specifies the listener for optimization events
      Specified by:
      withListener in interface Optimization
      Parameters:
      listener - the listener for optimization events
      Returns:
      the new instance of Optimization with configured listener
    • apply

      public CommandExecutor apply(CommandExecutor originalExecutor)
      Description copied from interface: Optimization
      Decorates command executor in order to apply optimization strategy.
      Specified by:
      apply in interface Optimization
      Parameters:
      originalExecutor - command executor that need to be optimized
      Returns:
      decorated command executor
    • apply

      public AsyncCommandExecutor apply(AsyncCommandExecutor originalExecutor)
      Description copied from interface: Optimization
      Decorates command executor in order to apply optimization strategy.
      Specified by:
      apply in interface Optimization
      Parameters:
      originalExecutor - command executor that need to be optimized
      Returns:
      decorated command executor