pub struct InMemoryBackend { /* private fields */ }Expand description
In-memory backend (simulates Redis)
Uses RwLock<HashMap> to store counters, simulating Redis’s INCR + EXPIRE behavior.
Suitable for single-machine scenarios and testing; not suitable for real distributed environments.
Implementations§
Trait Implementations§
Source§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§impl DistributedBackend for InMemoryBackend
impl DistributedBackend for InMemoryBackend
Source§fn incr_and_get(
&self,
key: &str,
window_secs: u64,
window_start: i64,
_max_requests: u64,
) -> Result<(u64, i64), RateLimitError>
fn incr_and_get( &self, key: &str, window_secs: u64, window_start: i64, _max_requests: u64, ) -> Result<(u64, i64), RateLimitError>
Atomically increments and returns the value after increment Read more
Auto Trait Implementations§
impl !Freeze for InMemoryBackend
impl RefUnwindSafe for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl UnwindSafe for InMemoryBackend
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