Class Bucket

java.lang.Object
dev.relism.flash.ext.limiter.Bucket

public final class Bucket extends Object
Pre-allocated per-key rate limit state. Holds two AtomicLong slots whose semantics are strategy-specific:
  • FIXED_WINDOW: slot0 = packed (epoch << 32 | count), slot1 unused.
  • SLIDING_WINDOW: slot0 = packed (epoch << 32 | count), slot1 = request count from the immediately preceding epoch.
  • TOKEN_BUCKET: slot0 = tokens × 1000 (scaled), slot1 = last-refill timestamp (ms since epoch).

Buckets are created once per unique key (via BucketStore) and reused for the lifetime of the server — zero allocation on the warm path.

  • Field Details

  • Constructor Details

    • Bucket

      public Bucket()