pub struct CacheManager { /* private fields */ }Expand description
缓存管理器
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub async fn new(config: CacheConfig) -> Result<Self>
pub async fn new(config: CacheConfig) -> Result<Self>
创建新的缓存管理器
Source§impl CacheManager
impl CacheManager
Sourcepub fn generate_query_cache_key(
&self,
table: &str,
conditions: &[QueryCondition],
options: &QueryOptions,
) -> String
pub fn generate_query_cache_key( &self, table: &str, conditions: &[QueryCondition], options: &QueryOptions, ) -> String
生成查询缓存键 - 优化版本,避免复杂序列化
Sourcepub fn generate_condition_groups_cache_key(
&self,
table: &str,
condition_groups: &[QueryConditionGroup],
options: &QueryOptions,
) -> String
pub fn generate_condition_groups_cache_key( &self, table: &str, condition_groups: &[QueryConditionGroup], options: &QueryOptions, ) -> String
生成条件组合查询缓存键
Source§impl CacheManager
impl CacheManager
Sourcepub async fn invalidate_table(&self, table: &str) -> Result<()>
pub async fn invalidate_table(&self, table: &str) -> Result<()>
清理表的所有缓存
Sourcepub async fn clear_by_pattern(&self, pattern: &str) -> Result<usize>
pub async fn clear_by_pattern(&self, pattern: &str) -> Result<usize>
Sourcepub async fn force_cleanup_expired(&self) -> Result<usize>
pub async fn force_cleanup_expired(&self) -> Result<usize>
强制清理过期缓存
手动触发过期缓存的清理,通常用于内存紧张或需要立即释放空间的场景
Sourcepub async fn cache_records_batch_optimized(
&self,
table: &str,
records: &[(IdType, DataValue)],
) -> Result<usize>
pub async fn cache_records_batch_optimized( &self, table: &str, records: &[(IdType, DataValue)], ) -> Result<usize>
Sourcepub async fn list_cache_keys(&self) -> Result<HashMap<String, Vec<String>>>
pub async fn list_cache_keys(&self) -> Result<HashMap<String, Vec<String>>>
获取所有缓存键列表(按表分组)
用于调试和监控,可以查看当前缓存中有哪些键
Sourcepub async fn clear_table_query_cache(&self, table: &str) -> Result<usize>
pub async fn clear_table_query_cache(&self, table: &str) -> Result<usize>
清理指定表的查询缓存
只清理查询缓存,保留记录缓存
Sourcepub async fn clear_table_record_cache(&self, table: &str) -> Result<usize>
pub async fn clear_table_record_cache(&self, table: &str) -> Result<usize>
清理指定表的记录缓存
只清理记录缓存,保留查询缓存
Sourcepub async fn get_stats(&self) -> Result<CacheStats>
pub async fn get_stats(&self) -> Result<CacheStats>
获取缓存统计信息
Sourcepub async fn get_performance_stats(&self) -> Result<CachePerformanceStats>
pub async fn get_performance_stats(&self) -> Result<CachePerformanceStats>
获取详细的性能统计信息
Sourcepub async fn reset_stats(&self) -> Result<()>
pub async fn reset_stats(&self) -> Result<()>
重置统计信息
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
检查缓存是否启用
Source§impl CacheManager
impl CacheManager
pub async fn cache_query_result( &self, table: &str, options: &QueryOptions, results: &[DataValue], ) -> Result<()>
Sourcepub async fn cache_condition_groups_result(
&self,
table: &str,
condition_groups: &[QueryConditionGroup],
options: &QueryOptions,
results: &[DataValue],
) -> Result<()>
pub async fn cache_condition_groups_result( &self, table: &str, condition_groups: &[QueryConditionGroup], options: &QueryOptions, results: &[DataValue], ) -> Result<()>
缓存条件组合查询结果
Sourcepub async fn get_cached_query_result(
&self,
table: &str,
options: &QueryOptions,
) -> Result<Option<Vec<DataValue>>>
pub async fn get_cached_query_result( &self, table: &str, options: &QueryOptions, ) -> Result<Option<Vec<DataValue>>>
获取缓存的查询结果 - 优化版本
Sourcepub async fn get_cached_condition_groups_result(
&self,
table: &str,
condition_groups: &[QueryConditionGroup],
options: &QueryOptions,
) -> Result<Option<Vec<DataValue>>>
pub async fn get_cached_condition_groups_result( &self, table: &str, condition_groups: &[QueryConditionGroup], options: &QueryOptions, ) -> Result<Option<Vec<DataValue>>>
获取缓存的条件组合查询结果
Trait Implementations§
Source§impl Clone for CacheManager
impl Clone for CacheManager
Source§fn clone(&self) -> CacheManager
fn clone(&self) -> CacheManager
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 moreAuto Trait Implementations§
impl Freeze for CacheManager
impl !RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl !UnwindSafe for CacheManager
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.