pub struct RateLimiter { /* private fields */ }Expand description
速率限制器(高性能版本,使用 DashMap)
Implementations§
Source§impl RateLimiter
impl RateLimiter
pub fn new() -> Self
pub fn with_config(config: RateLimitConfig) -> Self
Sourcepub fn get_status(&self, key: &str) -> RateLimitStatus
pub fn get_status(&self, key: &str) -> RateLimitStatus
获取指定 key 的状态
Sourcepub fn cleanup_expired(&self, max_age: Duration)
pub fn cleanup_expired(&self, max_age: Duration)
清理过期的条目(定期维护)
Sourcepub fn active_keys(&self) -> usize
pub fn active_keys(&self) -> usize
获取当前活跃的 key 数量
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RateLimiter
impl Freeze for RateLimiter
impl Send for RateLimiter
impl Sync for RateLimiter
impl Unpin for RateLimiter
impl UnsafeUnpin for RateLimiter
impl UnwindSafe for RateLimiter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more