pub struct QueryCache { /* private fields */ }Expand description
Per-request query cache backed by MemoryStore.
Implementations§
Source§impl QueryCache
impl QueryCache
Sourcepub fn cache_key(sql: &str, binds: &[Value]) -> String
pub fn cache_key(sql: &str, binds: &[Value]) -> String
Computes the cache key for an SQL statement and bind values.
Sourcepub fn with_request_scope<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn with_request_scope<F, R>(&self, f: F) -> Rwhere
F: FnOnce() -> R,
Runs f with an isolated request-scoped query cache.
Sourcepub fn fetch<F>(&self, sql: &str, binds: &[Value], loader: F) -> Value
pub fn fetch<F>(&self, sql: &str, binds: &[Value], loader: F) -> Value
Reads a cached query result or computes and stores it.
Sourcepub fn execute_write<F, R>(&self, operation: F) -> Rwhere
F: FnOnce() -> R,
pub fn execute_write<F, R>(&self, operation: F) -> Rwhere
F: FnOnce() -> R,
Clears cached query results after a write operation.
Trait Implementations§
Source§impl Clone for QueryCache
impl Clone for QueryCache
Source§fn clone(&self) -> QueryCache
fn clone(&self) -> QueryCache
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryCache
impl Debug for QueryCache
Auto Trait Implementations§
impl Freeze for QueryCache
impl !RefUnwindSafe for QueryCache
impl Send for QueryCache
impl Sync for QueryCache
impl Unpin for QueryCache
impl UnsafeUnpin for QueryCache
impl !UnwindSafe for QueryCache
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more