pub struct Store<E, K, V, T>{ /* private fields */ }Expand description
An unauthenticated key-value database based off of an append-only Journal of operations.
Implementations§
Source§impl<E, K, V, T> Store<E, K, V, T>
impl<E, K, V, T> Store<E, K, V, T>
Sourcepub async fn init(
context: E,
cfg: Config<T, <Operation<K, V> as Read>::Cfg>,
) -> Result<Self, Error>
pub async fn init( context: E, cfg: Config<T, <Operation<K, V> as Read>::Cfg>, ) -> Result<Self, Error>
Sourcepub async fn get(&self, key: &K) -> Result<Option<V>, Error>
pub async fn get(&self, key: &K) -> Result<Option<V>, Error>
Get the value of key in the db, or None if it has no value.
Sourcepub const fn op_count(&self) -> Location
pub const fn op_count(&self) -> Location
The number of operations that have been applied to this db, including those that have been pruned and those that are not yet committed.
Sourcepub const fn inactivity_floor_loc(&self) -> Location
pub const fn inactivity_floor_loc(&self) -> Location
Return the inactivity floor location. This is the location before which all operations are known to be inactive. Operations before this point can be safely pruned.
Sourcepub async fn get_metadata(&self) -> Result<Option<V>, Error>
pub async fn get_metadata(&self) -> Result<Option<V>, Error>
Get the metadata associated with the last commit.
Sourcepub async fn update(&mut self, key: K, value: V) -> Result<(), Error>
pub async fn update(&mut self, key: K, value: V) -> Result<(), Error>
Updates key to have value value. The operation is reflected in the snapshot, but will be
subject to rollback until the next successful commit.
Sourcepub async fn create(&mut self, key: K, value: V) -> Result<bool, Error>
pub async fn create(&mut self, key: K, value: V) -> Result<bool, Error>
Creates a new key-value pair in the db. The operation is reflected in the snapshot, but will
be subject to rollback until the next successful commit. Returns true if the key was
created, false if it already existed.
Sourcepub async fn delete(&mut self, key: K) -> Result<bool, Error>
pub async fn delete(&mut self, key: K) -> Result<bool, Error>
Delete key and its value from the db. Deleting a key that already has no value is a no-op.
The operation is reflected in the snapshot, but will be subject to rollback until the next
successful commit. Returns true if the key was deleted, false if it was already inactive.
Sourcepub async fn commit(
&mut self,
metadata: Option<V>,
) -> Result<Range<Location>, Error>
pub async fn commit( &mut self, metadata: Option<V>, ) -> Result<Range<Location>, Error>
Commit any pending operations to the database, ensuring their durability upon return from
this function. Also raises the inactivity floor according to the schedule. Returns the
(start_loc, end_loc] location range of committed operations. The end of the returned range
includes the commit operation itself, and hence will always be equal to op_count.
Failures after commit (but before sync or close) may still require reprocessing to
recover the database on restart.
Sourcepub async fn sync(&mut self) -> Result<(), Error>
pub async fn sync(&mut self) -> Result<(), Error>
Sync all database state to disk. While this isn’t necessary to ensure durability of committed operations, periodic invocation may reduce memory usage and the time required to recover the database on restart.
Sourcepub async fn prune(&mut self, prune_loc: Location) -> Result<(), Error>
pub async fn prune(&mut self, prune_loc: Location) -> Result<(), Error>
Prune historical operations prior to prune_loc. This does not affect the db’s root
or current snapshot.
Trait Implementations§
Source§impl<E, K, V, T> Batchable for Store<E, K, V, T>
impl<E, K, V, T> Batchable for Store<E, K, V, T>
Source§impl<E, K, V, T> LogStore for Store<E, K, V, T>
impl<E, K, V, T> LogStore for Store<E, K, V, T>
type Value = V
Source§fn op_count(&self) -> Location
fn op_count(&self) -> Location
Source§fn inactivity_floor_loc(&self) -> Location
fn inactivity_floor_loc(&self) -> Location
Source§impl<E, K, V, T> LogStorePrunable for Store<E, K, V, T>
impl<E, K, V, T> LogStorePrunable for Store<E, K, V, T>
Source§impl<E, K, V, T> StoreDeletable for Store<E, K, V, T>
impl<E, K, V, T> StoreDeletable for Store<E, K, V, T>
Source§impl<E, K, V, T> StoreMut for Store<E, K, V, T>
impl<E, K, V, T> StoreMut for Store<E, K, V, T>
Source§async fn update(
&mut self,
key: Self::Key,
value: Self::Value,
) -> Result<(), Self::Error>
async fn update( &mut self, key: Self::Key, value: Self::Value, ) -> Result<(), Self::Error>
Source§impl<E, K, V, T> StorePersistable for Store<E, K, V, T>
impl<E, K, V, T> StorePersistable for Store<E, K, V, T>
Auto Trait Implementations§
impl<E, K, V, T> Freeze for Store<E, K, V, T>
impl<E, K, V, T> !RefUnwindSafe for Store<E, K, V, T>
impl<E, K, V, T> Send for Store<E, K, V, T>
impl<E, K, V, T> Sync for Store<E, K, V, T>
impl<E, K, V, T> Unpin for Store<E, K, V, T>
impl<E, K, V, T> !UnwindSafe for Store<E, K, V, T>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 more