Struct sqlx_core::common::StatementCache
source · pub struct StatementCache<T> { /* private fields */ }
Expand description
A cache for prepared statements. When full, the least recently used statement gets removed.
Implementations§
source§impl<T> StatementCache<T>
impl<T> StatementCache<T>
sourcepub fn get_mut(&mut self, k: &str) -> Option<&mut T>
pub fn get_mut(&mut self, k: &str) -> Option<&mut T>
Returns a mutable reference to the value corresponding to the given key in the cache, if any.
sourcepub fn insert(&mut self, k: &str, v: T) -> Option<T>
pub fn insert(&mut self, k: &str, v: T) -> Option<T>
Inserts a new statement to the cache, returning the least recently used statement id if the cache is full, or if inserting with an existing key, the replaced existing statement.
sourcepub fn remove_lru(&mut self) -> Option<T>
pub fn remove_lru(&mut self) -> Option<T>
Removes the least recently used item from the cache.
sourcepub fn contains_key(&mut self, k: &str) -> bool
pub fn contains_key(&mut self, k: &str) -> bool
True if cache has a value for the given key.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if the cache capacity is more than 0.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for StatementCache<T>
impl<T> RefUnwindSafe for StatementCache<T>where
T: RefUnwindSafe,
impl<T> Send for StatementCache<T>where
T: Send,
impl<T> Sync for StatementCache<T>where
T: Sync,
impl<T> Unpin for StatementCache<T>
impl<T> UnwindSafe for StatementCache<T>where
T: RefUnwindSafe,
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 more