pub struct CacheService {
pub inner: Box<dyn ICacheService>,
}Fields§
§inner: Box<dyn ICacheService>Implementations§
Source§impl CacheService
impl CacheService
pub fn new(cfg: &ApplicationConfig) -> Self
pub fn new_saved(cfg: &ApplicationConfig) -> Self
pub async fn set_string(&self, k: &str, v: &str) -> Result<String>
pub async fn get_string(&self, k: &str) -> Result<String>
pub async fn del_string(&self, k: &str) -> Result<String>
pub async fn set_json<T>(&self, k: &str, v: &T) -> Result<String>
pub async fn get_json<T>(&self, k: &str) -> Result<T>where
T: DeserializeOwned + Sync,
pub async fn set_string_ex( &self, k: &str, v: &str, ex: Option<Duration>, ) -> Result<String>
Sourcepub async fn set_string_ex_nx(
&self,
k: &str,
v: &str,
ex: Option<Duration>,
) -> Result<bool>
pub async fn set_string_ex_nx( &self, k: &str, v: &str, ex: Option<Duration>, ) -> Result<bool>
原子操作:仅当 key 不存在时设置值并设置过期时间 返回 true 表示设置成功(key 原本不存在),false 表示设置失败(key 已存在)
pub async fn ttl(&self, k: &str) -> Result<i64>
Auto Trait Implementations§
impl !RefUnwindSafe for CacheService
impl !UnwindSafe for CacheService
impl Freeze for CacheService
impl Send for CacheService
impl Sync for CacheService
impl Unpin for CacheService
impl UnsafeUnpin for CacheService
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