What problem does it solve?
Fixed-window rate limiters suffer boundary bursts and full-window lockouts, and DRF throttles cannot refund charges for requests that did no work. This Skill guides you to implement a Redis-backed token bucket with continuous refill, atomic Lua operations, and accurate per-caller Retry-After values.
Core Features & Use Cases
- Atomic consume/refund/peek API: Charge tokens, return them when a request did no work, and introspect budgets without charging, all via server-side Lua scripts over posthog.redis.get_client().
- Accurate throttling semantics: Get real per-caller Retry-After waits and RateLimit-Limit/Remaining/Reset headers instead of window-edge guesses.
- Use Case: You are adding a per-partner rate limit to an API endpoint where callers burst legitimately, failed validations must refund their token, and 429 responses need a truthful Retry-After header.
Quick Start
Add a Redis token bucket rate limit to my endpoint using posthog/token_bucket.py with a burst of 30 and 120 requests per hour, refunding the token when the request does no work.