Skip to main content

bucket_ttl_secs

Function bucket_ttl_secs 

pub fn bucket_ttl_secs(config: RateLimitConfig) -> u64
Expand description

How long an idle bucket stays relevant: the time to refill a full bucket plus a minute of slack, clamped to [60s, 24h].

Lives in cratestack-core rather than in either store because BOTH need it and they must not drift: cratestack-redis passes the result to its Lua script as the EXPIRE argument (the script used to compute the same arithmetic itself), and cratestack-axum’s in-memory store uses it as the eviction horizon for its sweep (cratestack#871). A divergence would mean the two backends bound their keyspaces differently for identical configuration — exactly the class of silent backend-specific behaviour the store trait exists to prevent.

refill_per_second <= 0 means the bucket never refills, so there is no “time to refill” to derive from; it gets the 24h clamp.