Reported interview periodApr 2026
Token-Bucket State Transitions
Each subject has a token bucket stored in a shared key-value cache. A missing bucket begins full. Refill lazily when a request arrives: add elapsed_time * refill_rate, capped at capacity. If time has not advanc…
Practice focusAccept only when the refilled balance covers the full request, then subtract it. A rejected request spends nothing. Persist the refilled state in either case. A backward-moving clock must not create tokens. TokenBucket and the in-memory DistributedCache test double are provided. This base task is sequential; the cache name does not imply atomic distributed behavior. Refill returns a new bucket without editing its argument. Existing buckets retain their stored capacity/refill rate; call configuration initializes missing buckets only.…