pub struct MemoryStore {
pub windows: Mutex<HashMap<String, Vec<(f64, f64)>>>,
pub bans: Mutex<HashMap<String, f64>>,
pub fail: AtomicBool,
}Expand description
An in-memory backend for the distributed paths: the same operations a Redis runs, keyed the same way, so the engine’s store paths are testable without a backend process.
Fields§
§windows: Mutex<HashMap<String, Vec<(f64, f64)>>>§bans: Mutex<HashMap<String, f64>>§fail: AtomicBoolWhen set, every operation fails (the fail-closed/fail-open tests).
Trait Implementations§
Source§impl BanStore for MemoryStore
impl BanStore for MemoryStore
Source§fn set_ban(
&self,
key: &str,
expiry: f64,
_ttl_seconds: u64,
) -> Result<(), StoreError>
fn set_ban( &self, key: &str, expiry: f64, _ttl_seconds: u64, ) -> Result<(), StoreError>
SET key expiry EX ttl with the expiry as unix seconds (the
reference set_key("banned_ips", ip, str(expiry), ttl=duration)). Read moreSource§fn get_ban(&self, key: &str) -> Result<Option<f64>, StoreError>
fn get_ban(&self, key: &str) -> Result<Option<f64>, StoreError>
GET key, parsed to the stored expiry unix seconds. Read moreSource§fn delete_ban(&self, key: &str) -> Result<(), StoreError>
fn delete_ban(&self, key: &str) -> Result<(), StoreError>
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl SlidingWindowStore for MemoryStore
impl SlidingWindowStore for MemoryStore
Source§fn record_hit(
&self,
key: &str,
now: f64,
window: u64,
) -> Result<u64, StoreError>
fn record_hit( &self, key: &str, now: f64, window: u64, ) -> Result<u64, StoreError>
Record one hit at
now into the window key and return the
post-eviction ZCARD count. The four reference operations run
atomically (one transaction). Read moreAuto Trait Implementations§
impl !Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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