pub struct CacheManager { /* private fields */ }Expand description
缓存管理器
全局单例或通过依赖注入管理,负责:
- Redis 连接管理
- Key 索引维护
- 插件缓存清理
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub async fn new(
redis_url: &str,
config: CacheConfig,
) -> Result<Self, CacheError>
pub async fn new( redis_url: &str, config: CacheConfig, ) -> Result<Self, CacheError>
Sourcepub async fn new_with_defaults(redis_url: &str) -> Result<Self, CacheError>
pub async fn new_with_defaults(redis_url: &str) -> Result<Self, CacheError>
Sourcepub fn create_plugin_cache(&self, plugin_id: String) -> PluginCache
pub fn create_plugin_cache(&self, plugin_id: String) -> PluginCache
Sourcepub async fn clear_plugin(&self, plugin_id: &str) -> Result<u64, CacheError>
pub async fn clear_plugin(&self, plugin_id: &str) -> Result<u64, CacheError>
Sourcepub async fn clear_plugin_for_upgrade(
&self,
plugin_id: &str,
) -> Result<u64, CacheError>
pub async fn clear_plugin_for_upgrade( &self, plugin_id: &str, ) -> Result<u64, CacheError>
Sourcepub async fn clear_plugin_for_disable(
&self,
plugin_id: &str,
force: bool,
) -> Result<u64, CacheError>
pub async fn clear_plugin_for_disable( &self, plugin_id: &str, force: bool, ) -> Result<u64, CacheError>
Sourcepub async fn clear_module(
&self,
plugin_id: &str,
module: &str,
) -> Result<u64, CacheError>
pub async fn clear_module( &self, plugin_id: &str, module: &str, ) -> Result<u64, CacheError>
清理指定插件的指定模块缓存
§Arguments
plugin_id- 插件 IDmodule- 模块标识(biz),如user、order、config等
§Returns
Result<u64, CacheError>- 删除的 Key 数量
§Example
// 清空 user_plugin 插件的 user 模块缓存
cache_manager.clear_module("user_plugin", "user").await?;
// 清空 order_service 插件的 order 模块缓存
cache_manager.clear_module("order_service", "order").await?;Sourcepub async fn health_check(&self) -> Result<(), CacheError>
pub async fn health_check(&self) -> Result<(), CacheError>
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