finds.dev

go-redis/redis_rate

Rate limiting for go-redis

View on GitHubHomepage ↗

★ 1,024GoBSD-2-Clauseupdated Jun 2026

// the take

A GCRA-based rate limiter backed by Redis, implemented as a thin Go library. It runs the entire rate-limiting logic atomically in a Lua script on the Redis side, so there are no race conditions across multiple app instances. Aimed at Go services already using go-redis that need per-key distributed rate limiting without pulling in a separate service.

The Lua-script-in-Redis approach gives you atomic check-and-decrement in a single round-trip, which is the right way to do this. The Result struct exposes RetryAfter and ResetAfter, so callers can build proper 429 responses with Retry-After headers without guessing. The PerSecond/PerMinute/PerHour helpers make common cases one-liners. The codebase is small enough to read in an afternoon — lua.go and rate.go are the whole implementation.

No support for redis.ClusterClient or redis.Ring — the Lua EVAL approach only works against a single node or a sentinel setup, which will bite anyone running Redis Cluster. The README still references the old go-redis/redis import path while the example uses redis/go-redis, which is confusing and a frequent copy-paste trap. The Travis CI badge points to a dead pipeline, and there's no GitHub Actions workflow covering it. No built-in support for burst allowances beyond what GCRA inherently provides — if you want token-bucket semantics with a separate burst cap, you're extending this yourself.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
1,024
Forks
107
Language
Go
License
BSD-2-Clause
Last commit
22 Jun 2026

// nearby

If redis_rate isn't quite it.

All repos →