pub struct CachePlugin { /* private fields */ }Expand description
缓存插件 —— 管理缓存实例的生命周期
在 start() 时根据配置自动创建 LocalCache 或 RedisCache,
stop() 时释放连接。
Implementations§
Source§impl CachePlugin
impl CachePlugin
Sourcepub fn new(cache_config: &CacheConfig, redis_config: &RedisConfig) -> Self
pub fn new(cache_config: &CacheConfig, redis_config: &RedisConfig) -> Self
创建缓存插件
Sourcepub fn cache(&self) -> Option<SharedCache>
pub fn cache(&self) -> Option<SharedCache>
获取缓存实例(需在 start 之后调用)
Trait Implementations§
Source§impl Plugin for CachePlugin
impl Plugin for CachePlugin
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
启动插件:验证连接、初始化资源 Read more
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
关闭插件:释放资源 Read more
Source§fn depends_on(&self) -> &[&str]
fn depends_on(&self) -> &[&str]
依赖的其他插件名称(用于拓扑排序,保证启动顺序) Read more
Auto Trait Implementations§
impl !Freeze for CachePlugin
impl !RefUnwindSafe for CachePlugin
impl Send for CachePlugin
impl Sync for CachePlugin
impl Unpin for CachePlugin
impl UnsafeUnpin for CachePlugin
impl !UnwindSafe for CachePlugin
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