Skip to content

Releases: kasapdev/php-rate-limiter

v1.2.0

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:01

Adds LeakyBucketLimiter, a new leaky bucket rate limiting algorithm alongside the existing token bucket and sliding window limiters.

Each key gets a fixed-capacity queue that leaks (drains) at a constant configured rate (requests/second). Every attempt() first leaks the bucket based on elapsed wall-clock time since the last recorded state, then either queues the request (returns true) or rejects it outright (returns false) if the bucket is already at capacity.

  • Reuses the existing pluggable StorageInterface (works with both ArrayStorage and FileStorage) — no new storage mechanism.
  • Follows the same constructor/method conventions as TokenBucketLimiter and SlidingWindowLimiter: __construct(StorageInterface $storage, int $capacity, float $leakRatePerSecond), attempt(string $key): bool, remaining(string $key): int.
  • New deterministic tests cover capacity exhaustion, leak-over-time behavior (simulated via direct storage timestamp manipulation, no sleep()), the zero-capacity edge case, and FileStorage interoperability.
  • README: new '## Leaky Bucket Limiter' usage section with a runnable example, an updated API reference, and a new realistic end-to-end HTTP rate-limiting middleware example under '## Usage'.

v1.1.0

Choose a tag to compare

@kasapdev kasapdev released this 06 Sep 01:21

Adds edge-case regression tests: FileStorage handling of corrupted JSON files and key-collision independence, TokenBucketLimiter with cost=0/capacity=0, and SlidingWindowLimiter with maxRequests=0. No behavioral changes; all tests pass.

v1.0.0

Choose a tag to compare

@kasapdev kasapdev released this 05 Sep 23:41

Initial stable release.