pub struct MemoryKvStore { /* private fields */ }Expand description
A KvStore in memory.
An entry that has expired is removed as the store is written to, not only when its own key is next asked for: most keys are never asked for again — an actor seen once, an activity processed once — and a store that waited for that would grow for as long as its process ran.
MemoryKvStore::with_capacity also bounds how many entries it holds,
dropping those nearest to expiring first. Everything Ojak keeps here is a
cache, so an entry dropped early costs a refetch, or for an activity’s ID,
a duplicate the application’s own writes have to tolerate anyway.
Implementations§
Source§impl MemoryKvStore
impl MemoryKvStore
pub fn new() -> Self
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Trait Implementations§
Source§impl Debug for MemoryKvStore
impl Debug for MemoryKvStore
Source§impl Default for MemoryKvStore
impl Default for MemoryKvStore
Source§fn default() -> MemoryKvStore
fn default() -> MemoryKvStore
Returns the “default value” for a type. Read more
Source§impl KvStore for MemoryKvStore
impl KvStore for MemoryKvStore
Source§async fn set(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> Result<(), KvError>
async fn set( &self, key: &[&str], value: Value, ttl: Option<Duration>, ) -> Result<(), KvError>
Put
value under key, replacing what was there, to expire after
ttl if given.Source§async fn insert(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> Result<bool, KvError>
async fn insert( &self, key: &[&str], value: Value, ttl: Option<Duration>, ) -> Result<bool, KvError>
Put
value under key only if nothing is there, and say whether it
was put. Of any number of callers at once, in any number of
processes, exactly one is told it was: this is what makes “has this
activity been processed?” safe to ask from two workers.Auto Trait Implementations§
impl !Freeze for MemoryKvStore
impl RefUnwindSafe for MemoryKvStore
impl Send for MemoryKvStore
impl Sync for MemoryKvStore
impl Unpin for MemoryKvStore
impl UnsafeUnpin for MemoryKvStore
impl UnwindSafe for MemoryKvStore
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