Class 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:
    DelayParameters
    • Method Detail

      • 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