Summary
Add a Redis-backed ratelimit.Store implementation for distributed rate limiting.
Context
The ratelimit middleware defines:
type Store interface {
Allow(key string) (allowed bool, remaining int, resetAt time.Time, err error)
}
Currently uses a sharded in-memory token bucket. For multi-instance deployments, rate limits must be shared via Redis.
Scope
- Implement
RedisStore satisfying ratelimit.Store (and optionally StoreUndo)
- Use Lua script for atomic check-and-decrement (EVALSHA)
- Sliding window or token bucket algorithm in Redis
- Key prefix configurable (default:
rl:)
- TTL auto-set from the rate window
- Use celeris's native Redis driver
Design Principle
The adapter depends on the existing Store interface — no changes to the ratelimit middleware itself.
Summary
Add a Redis-backed
ratelimit.Storeimplementation for distributed rate limiting.Context
The ratelimit middleware defines:
Currently uses a sharded in-memory token bucket. For multi-instance deployments, rate limits must be shared via Redis.
Scope
RedisStoresatisfyingratelimit.Store(and optionallyStoreUndo)rl:)Design Principle
The adapter depends on the existing
Storeinterface — no changes to the ratelimit middleware itself.