pub struct DatabaseStorage {}Expand description
数据库存储实现(占位符)
Implementations§
Source§impl DatabaseStorage
impl DatabaseStorage
Sourcepub async fn new(_database_url: &str) -> StorageResult<Self>
pub async fn new(_database_url: &str) -> StorageResult<Self>
创建新的数据库存储
Trait Implementations§
Source§impl SaStorage for DatabaseStorage
impl SaStorage for DatabaseStorage
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
获取值
Source§fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_value: &'life2 str,
_ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_value: &'life2 str,
_ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
设置值 Read more
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + 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 = StorageResult<bool>> + 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 = StorageResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
检查键是否存在
Source§fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn expire<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
设置过期时间
Source§fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<Duration>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<Duration>>> + 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 = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
清空所有数据(谨慎使用)
Source§fn mget<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<String>>, StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn mget<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<String>>, StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
批量获取
Source§fn mset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
items: &'life1 [(&'life2 str, &'life3 str)],
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn mset<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
items: &'life1 [(&'life2 str, &'life3 str)],
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
批量设置
Source§fn mdel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn mdel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
批量删除
Source§fn incr<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<i64, StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn incr<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<i64, StorageError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
原子递增