Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore: Send + Sync {
    // Required methods
    fn get<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CoolResult<Option<T>>> + Send + 'async_trait>>
       where T: 'async_trait + DeserializeOwned + Send,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        key: &'life1 str,
        value: &'life2 T,
        ttl: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn del<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CoolResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn keys<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pattern: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = CoolResult<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

缓存 trait

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait, T>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CoolResult<Option<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

获取缓存

Source

fn set<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, key: &'life1 str, value: &'life2 T, ttl: Option<Duration>, ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

设置缓存

Source

fn del<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

删除缓存

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = CoolResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

检查缓存是否存在

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CoolResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

清空所有缓存

Source

fn keys<'life0, 'life1, 'async_trait>( &'life0 self, pattern: &'life1 str, ) -> Pin<Box<dyn Future<Output = CoolResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

获取所有 key

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§