pub struct CachingStoreManager<T> { /* private fields */ }
Expand description
Wrap each Store
produced by the inner StoreManager
in an asynchronous,
write-behind cache.
This serves two purposes:
-
Improve performance with slow and/or distant stores
-
Provide a relaxed consistency guarantee vs. what a fully synchronous store provides
The latter is intended to prevent guests from coming to rely on the synchronous consistency model of an existing implementation which may later be replaced with one providing a more relaxed, asynchronous (i.e. “eventual”) consistency model. See also https://www.hyrumslaw.com/ and https://xkcd.com/1172/.
This implementation provides a “read-your-writes”, asynchronous consistency model such that values are immediately available for reading as soon as they are written as long as the read(s) hit the same cache as the write(s). Reads and writes through separate caches (e.g. separate guest instances or separately-opened references to the same store within a single instance) are not guaranteed to be consistent; not only is cross-cache consistency subject to scheduling and/or networking delays, a given tuple is never refreshed from the backing store once added to a cache since this implementation is intended for use only by short-lived guest instances.
Note that, because writes are asynchronous and return immediately,
durability is not guaranteed. I/O errors may occur asynchronously after
the write operation has returned control to the guest, which may result in
the write being lost without the guest knowing. In the future, a separate
write-durable
function could be added to key-value.wit to provide either
synchronous or asynchronous feedback on durability for guests which need it.
Implementations§
Source§impl<T> CachingStoreManager<T>
impl<T> CachingStoreManager<T>
pub fn new(inner: T) -> Self
pub fn new_with_capacity(capacity: NonZeroUsize, inner: T) -> Self
Trait Implementations§
Source§impl<T: StoreManager> StoreManager for CachingStoreManager<T>
impl<T: StoreManager> StoreManager for CachingStoreManager<T>
Auto Trait Implementations§
impl<T> Freeze for CachingStoreManager<T>where
T: Freeze,
impl<T> RefUnwindSafe for CachingStoreManager<T>where
T: RefUnwindSafe,
impl<T> Send for CachingStoreManager<T>where
T: Send,
impl<T> Sync for CachingStoreManager<T>where
T: Sync,
impl<T> Unpin for CachingStoreManager<T>where
T: Unpin,
impl<T> UnwindSafe for CachingStoreManager<T>where
T: UnwindSafe,
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
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