Skip to main content

MemoryKv

Struct MemoryKv 

Source
pub struct MemoryKv { /* private fields */ }
Expand description

In-process KvStore impl.

Implementations§

Source§

impl MemoryKv

Source

pub fn new() -> Self

Build an empty store.

Trait Implementations§

Source§

impl Default for MemoryKv

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more