pub struct LocalKv { /* private fields */ }Expand description
Local disk-persisted KV implementation using sled embedded database
This provides a persistent, thread-safe, disk-based key-value store that implements all KV trait features including TTL, conditional puts, and prefix scanning. Perfect for local development and testing that needs data persistence across restarts.
Implementations§
Source§impl LocalKv
impl LocalKv
Sourcepub async fn new(data_dir: PathBuf) -> Result<Self>
pub async fn new(data_dir: PathBuf) -> Result<Self>
Create a new local KV store with the given data directory
Sourcepub async fn len(&self) -> Result<usize>
pub async fn len(&self) -> Result<usize>
Get the number of items currently stored (including expired items) Useful for testing
Trait Implementations§
Source§impl Kv for LocalKv
impl Kv for LocalKv
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a value by key. Returns None if key doesn’t exist or has expired. Read more
Source§fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
options: Option<PutOptions>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
options: Option<PutOptions>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Put a value with optional options. When options.if_not_exists is true, returns true if created,
false if already exists. When options.if_not_exists is false or options is None, always returns true. Read more
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a key. No error if key doesn’t exist. Read more
Source§fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a key exists without retrieving the value. Read more
Source§fn scan_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
limit: Option<usize>,
cursor: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<ScanResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn scan_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
limit: Option<usize>,
cursor: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<ScanResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Scan keys with a prefix, with pagination support. Read more
impl Binding for LocalKv
Auto Trait Implementations§
impl Freeze for LocalKv
impl !RefUnwindSafe for LocalKv
impl Send for LocalKv
impl Sync for LocalKv
impl Unpin for LocalKv
impl UnsafeUnpin for LocalKv
impl !UnwindSafe for LocalKv
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.