Changelog

v2.3.0

An allowed lag for hybrid read-only calls, so each instance sees increments from other instances.

Status: Released · November 12, 2026

Version 2.3.0 sets a maximum age for the local state that answers a hybrid read-only call. Only the hybrid provider changes.

Added

  • Added trypema::hybrid::AllowedLag. The default is 1 second and the minimum is 1 ms. It has the same shape as SyncInterval: milliseconds, seconds, minutes, and hours constructors that return Result, _or_panic forms, and as_milliseconds(), as_seconds(), as_minutes(), and as_hours() getters.
  • Added the hybrid builder setter allowed_lag(AllowedLag).
  • Added the hybrid builder setter allowed_lag_applies_to_rejections(bool). The default is false. With true, read-only answers from an absolute rejection cache are also at most allowed_lag old. The suppressed strategy does not use this setting.
  • Added the error variant TrypemaError::InvalidAllowedLag.
use trypema::RateLimiterBuilder;
use trypema::hybrid::{AllowedLag, HybridRateLimiterProvider};

let provider = HybridRateLimiterProvider::builder(connection)
    .allowed_lag(AllowedLag::milliseconds_or_panic(500))
    .allowed_lag_applies_to_rejections(true)
    .build()?;

Changed

The hybrid read-only calls are is_allowed and get_estimate on the absolute limiter, and get_suppression_factor and get_estimate on the suppressed limiter.

  • They answer from accepting local state only while it is younger than allowed_lag. Then they read Redis again. Concurrent calls for one key share that read. Thus an instance sees increments from other instances.
  • They record no activity. A key in accepting state that is only checked becomes stale, and cleanup removes it.
  • For a key with no stored limit, they keep a small local entry and create no Redis key. The entry answers until allowed_lag passes. Only the cleanup loop removes it.

Increments reach Redis within sync_interval. A read-only answer from accepting state or from the entry of a key with no stored limit is at most allowed_lag old. A cached rejection answers until its retry time ends, up to one window, unless allowed_lag_applies_to_rejections(true) is set. The suppression cache stays bounded by the suppression-factor cache period.

inc and try_inc decisions, the flush, and get do not change. get always reads Redis. The local and Redis providers do not change.

Fixed

  • A hybrid check of a key at its limit, with nothing pending, no longer writes an empty commit to Redis.

Before you upgrade

  • A hot key that is only checked now makes at most one Redis read per allowed_lag on each instance.
  • An unknown key that is checked now keeps a small local entry until cleanup removes it. If you disable cleanup, call start_cleanup_loop(), or these entries stay in memory.
  • A key in accepting state that is only checked is now removed by cleanup. Checks no longer keep it alive.

Performance

Criterion on an Apple M2 Pro, 2.2.1 compared with 2.3.0, Tokio runtime:

Benchmark2.2.12.3.0
hybrid suppressed get_suppression_factor, hot keyabout 50 nsabout 70 ns
hybrid absolute is_allowed, hot keyabout 70 nsabout 76 ns

All other benchmarks stay within noise (±3 %).

See Read-only calls.

trypema 2.3.0 on crates.io