pub struct MemoryStore { /* private fields */ }
Expand description
MemoryStore
is a simple implementation of Store that persists data in an in-memory
HashMap
.
Note that the implementation is currently not thread-safe and will need a mutex added if it’s ever used for anything serious.
Implementations§
Source§impl MemoryStore
impl MemoryStore
pub fn new() -> MemoryStore
pub fn new_verbose() -> MemoryStore
Trait Implementations§
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§fn default() -> MemoryStore
fn default() -> MemoryStore
Returns the “default value” for a type. Read more
Source§impl Store for MemoryStore
impl Store for MemoryStore
Source§fn compare_and_swap_with_ttl(
&mut self,
key: &str,
old: i64,
new: i64,
_: Duration,
) -> Result<bool, CellError>
fn compare_and_swap_with_ttl( &mut self, key: &str, old: i64, new: i64, _: Duration, ) -> Result<bool, CellError>
Compares the value at the given key with a known old value and swaps it
for a new value if and only if they’re equal. Also sets the key’s TTL
until it expires.
Source§fn get_with_time(&self, key: &str) -> Result<(i64, Tm), CellError>
fn get_with_time(&self, key: &str) -> Result<(i64, Tm), CellError>
Gets the given key’s value and the current time as dictated by the
store (this is done so that rate limiters running on a variety of
different nodes can operate with a consistent clock instead of using
their own). If the key was unset, -1 is returned.
Auto Trait Implementations§
impl Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin 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