pub struct PreparedStatementCache { /* private fields */ }Expand description
预备语句缓存(LRU 策略)。
缓存 SQL 语句到预备语句 ID 的映射,避免重复解析和编译 SQL。 使用 LRU(Least Recently Used)策略在容量满时驱逐最久未使用的条目。
§线程安全
内部使用 Mutex 保护,可安全跨线程共享。
LRU 排序基于单调递增的原子计数器,不受系统时钟精度影响。
Implementations§
Source§impl PreparedStatementCache
impl PreparedStatementCache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
获取缓存统计信息。
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
重置统计信息(不清空缓存条目)。
Trait Implementations§
Source§impl Debug for PreparedStatementCache
impl Debug for PreparedStatementCache
Auto Trait Implementations§
impl !Freeze for PreparedStatementCache
impl RefUnwindSafe for PreparedStatementCache
impl Send for PreparedStatementCache
impl Sync for PreparedStatementCache
impl Unpin for PreparedStatementCache
impl UnsafeUnpin for PreparedStatementCache
impl UnwindSafe for PreparedStatementCache
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