pub struct MemoryKv { /* private fields */ }Expand description
In-process KvStore impl.
Implementations§
Trait Implementations§
Source§impl KvStore for MemoryKv
impl KvStore for MemoryKv
Source§fn keys_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
cursor: Option<String>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<KeyPage, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn keys_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
cursor: Option<String>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<KeyPage, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Ranges the key-ordered map from the cursor, reading only limit(+1) keys
— no full-bucket rescan, unlike the trait default. limit is floored to
1 so a zero never stalls a page-walk.
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<KvEntry>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<KvEntry>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Read a value.
Source§fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
value: Bytes,
) -> Pin<Box<dyn Future<Output = Result<Revision, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
value: Bytes,
) -> Pin<Box<dyn Future<Output = Result<Revision, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Unconditional write. Returns the new revision.
Source§fn cas<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
value: Bytes,
expected: Option<Revision>,
) -> Pin<Box<dyn Future<Output = Result<Revision, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cas<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
value: Bytes,
expected: Option<Revision>,
) -> Pin<Box<dyn Future<Output = Result<Revision, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Compare-and-set.
expected = None requires the key to be absent;
Some(rev) requires the current revision to equal rev. Returns
the new revision on success.Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete a key.
Source§fn keys<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn keys<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Enumerate keys under
bucket. Default impl returns
BusError::Unsupported — backends that can scan (in-mem,
NATS JetStream KV) override this. The resume-buffer sweeper
(see klieo-core::resume) calls this to walk all buckets;
backends that cannot enumerate skip proactive eviction and
rely on access-time TTL checks.Source§fn scan_bucket<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Bytes)>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn scan_bucket<'life0, 'life1, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, Bytes)>, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return all
(key, value) pairs in bucket in a single logical
operation. The default falls back to Self::keys + per-key
Self::get (N+1); override for efficiency.Source§fn lease<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Lease, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn lease<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Lease, BusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Acquire an exclusive lease over
key for ttl. Implementations
should hold the lease as long as the returned Lease is live
and call its heartbeat to extend.Source§fn put_causer<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
run: RunId,
) -> Pin<Box<dyn Future<Output = Result<(), BusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn put_causer<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
run: RunId,
) -> Pin<Box<dyn Future<Output = Result<(), BusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Record which
run caused the value at key to be written, stored under
a reserved-prefix sibling key in the SAME bucket (no new bucket — NATS KV
bucket names are charset-restricted). First-writer-wins: the causer is
written create-if-absent, so a later writer never overwrites an existing
causer (a CAS conflict is the expected no-op, not an error). Best-effort
provenance, NOT atomic with the value write. The default is backed by
Self::cas; impls need not override.Source§fn causer_of<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunId>, BusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn causer_of<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
bucket: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<RunId>, BusError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Read the causer recorded by
Self::put_causer; None if no causer was
written or the stored value is not a valid run id.Auto Trait Implementations§
impl !RefUnwindSafe for MemoryKv
impl !UnwindSafe for MemoryKv
impl Freeze for MemoryKv
impl Send for MemoryKv
impl Sync for MemoryKv
impl Unpin for MemoryKv
impl UnsafeUnpin for MemoryKv
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