Changelog
v3.1.0
Each provider and limiter returns its window from window_size(), each limiter runs its own cleanup loop, and hybrid cleanup frees the per-key locks.
Status: Released · November 15, 2026
Version 3.1.0 adds one getter, changes how the stale-state cleanup loops run, and fixes a memory leak in the hybrid limiters.
Added
- Added
window_size(&self) -> WindowSizeto the three providers,LocalRateLimiterProvider,RedisRateLimiterProvider, andHybridRateLimiterProvider, and to the six limiters,AbsoluteLocalRateLimiter,SuppressedLocalRateLimiter,AbsoluteRedisRateLimiter,SuppressedRedisRateLimiter,AbsoluteHybridRateLimiter, andSuppressedHybridRateLimiter. - The getter returns the builder's
window_size, or the default of 10 seconds when the builder did not set one. A limiter that a provider owns returns the window of that provider.
use std::sync::Arc;
use trypema::{RateLimiterBuilder, WindowSize};
use trypema::local::AbsoluteLocalRateLimiter;
let limiter: Arc<AbsoluteLocalRateLimiter> = RateLimiterBuilder::local()
.window_size(WindowSize::seconds_or_panic(90))
.build()?;
assert_eq!(limiter.window_size(), WindowSize::seconds_or_panic(90));
Changed
- A provider runs one cleanup loop for each of its two limiters, in place of one loop for both.
start_cleanup_loop()andstop_cleanup_loop()on a provider start and stop the two loops. provider.absolute().stop_cleanup_loop()stops the cleanup of the absolute strategy only, andprovider.suppressed().stop_cleanup_loop()stops the cleanup of the suppressed strategy only.stop_cleanup_loop(), or the drop of the lastArc, ends a cleanup loop at once, not at its next wake up to one cleanup interval later. A pass that runs at that time completes first.- A failed cleanup pass of one strategy does not stop the cleanup of the other strategy, because each strategy has its own loop.
start_cleanup_loop()on a provider takes&self, in place ofself: &Arc<Self>. Calls on anArcof a provider compile as before.
Fixed
- The hybrid limiters keep one lock for each key, so that only one call at a time reads Redis and
updates the local state of that key. Cleanup removed the stale state of a key but kept its lock,
and
deletedid the same. The lock map grew with each distinct key, for example each client IP of a limiter keyed by IP. A cleanup pass now removes each lock that no call holds or waits on. The next call to that key makes a new lock.
Before you upgrade
No migration is necessary. Code that builds with 3.0 builds with 3.1.

