Skip to content

feat(ratelimit): implement all three algorithms for Redis store#11

Merged
alexferl merged 1 commit into
masterfrom
ratelimit
Apr 2, 2026
Merged

feat(ratelimit): implement all three algorithms for Redis store#11
alexferl merged 1 commit into
masterfrom
ratelimit

Conversation

@alexferl

@alexferl alexferl commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Add support for TokenBucket and FixedWindow algorithms in addition to
the existing SlidingWindow implementation.

  • TokenBucket: Lua script for atomic token refill/deduct with burst support
  • FixedWindow: Simple INCR+EXPIRE counter with window-based reset
  • SlidingWindow: Existing sorted set implementation (renamed to checkSlidingWindow)
  • Each algorithm uses distinct key prefix (tb:, fw:, sw:) to avoid collisions
  • Add comprehensive tests for all three algorithms

Also fix adapters/huma test mock to use correct MiddlewareFunc type.

  Add support for TokenBucket and FixedWindow algorithms in addition to
  the existing SlidingWindow implementation.

  - TokenBucket: Lua script for atomic token refill/deduct with burst support
  - FixedWindow: Simple INCR+EXPIRE counter with window-based reset
  - SlidingWindow: Existing sorted set implementation (renamed to checkSlidingWindow)
  - Each algorithm uses distinct key prefix (tb:, fw:, sw:) to avoid collisions
  - Add comprehensive tests for all three algorithms

  Also fix adapters/huma test mock to use correct MiddlewareFunc type.

Signed-off-by: alexferl <me@alexferl.com>
@alexferl alexferl merged commit 60b09e0 into master Apr 2, 2026
137 of 138 checks passed
@alexferl alexferl deleted the ratelimit branch April 2, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant