Trait CacheBase

Source
pub trait CacheBase {
Show 18 methods // Required methods fn db(&mut self, db: i8) -> Result<&mut dyn CacheBase, String>; fn add( &mut self, key: &str, value: JsonValue, expiration_date: u64, ) -> Result<bool, String>; fn get(&mut self, key: &str) -> Result<JsonValue, String>; fn delete(&mut self, key: &str) -> Result<bool, String>; fn exists(&mut self, key: &str) -> Result<bool, String>; fn keys(&mut self, key: &str) -> Result<JsonValue, String>; fn set_add(&mut self, key: &str, value: JsonValue) -> Result<bool, String>; fn set_get(&mut self, key: &str) -> Result<JsonValue, String>; fn set_delete( &mut self, key: &str, value: JsonValue, ) -> Result<bool, String>; fn set_message_queue( &mut self, key: &str, value: JsonValue, ) -> Result<bool, String>; fn get_message_queue(&mut self, key: &str) -> Result<JsonValue, String>; fn set_object( &mut self, key: &str, field: &str, value: JsonValue, ) -> Result<bool, String>; fn get_object(&mut self, key: &str) -> Result<JsonValue, String>; fn add_hash( &mut self, key: &str, field: &str, value: JsonValue, ) -> Result<bool, String>; fn get_hash_field_value( &mut self, key: &str, field: &str, ) -> Result<JsonValue, String>; fn get_hash_fields(&mut self, key: &str) -> Result<JsonValue, String>; fn delete_hash(&mut self, key: &str, field: &str) -> Result<bool, String>; fn get_hash_values(&mut self, key: &str) -> Result<JsonValue, String>;
}

Required Methods§

Source

fn db(&mut self, db: i8) -> Result<&mut dyn CacheBase, String>

选择数据库

Source

fn add( &mut self, key: &str, value: JsonValue, expiration_date: u64, ) -> Result<bool, String>

设置缓存

  • expiration_date 过期时间 s 秒
Source

fn get(&mut self, key: &str) -> Result<JsonValue, String>

获取缓存

Source

fn delete(&mut self, key: &str) -> Result<bool, String>

删除缓存

Source

fn exists(&mut self, key: &str) -> Result<bool, String>

exists 判断KEY是否存在

  • key 键
Source

fn keys(&mut self, key: &str) -> Result<JsonValue, String>

查询 KEY

  • key 键 格式 * 或 *#### 模糊查询
Source

fn set_add(&mut self, key: &str, value: JsonValue) -> Result<bool, String>

集合 添加

Source

fn set_get(&mut self, key: &str) -> Result<JsonValue, String>

集合 获取

Source

fn set_delete(&mut self, key: &str, value: JsonValue) -> Result<bool, String>

集合 删除

Source

fn set_message_queue( &mut self, key: &str, value: JsonValue, ) -> Result<bool, String>

设置消息队列

Source

fn get_message_queue(&mut self, key: &str) -> Result<JsonValue, String>

获取消息队列

Source

fn set_object( &mut self, key: &str, field: &str, value: JsonValue, ) -> Result<bool, String>

Source

fn get_object(&mut self, key: &str) -> Result<JsonValue, String>

获取哈希值

Source

fn add_hash( &mut self, key: &str, field: &str, value: JsonValue, ) -> Result<bool, String>

添加哈希

Source

fn get_hash_field_value( &mut self, key: &str, field: &str, ) -> Result<JsonValue, String>

获取哈希指定key的字段值

Source

fn get_hash_fields(&mut self, key: &str) -> Result<JsonValue, String>

获取key下所有的field

Source

fn delete_hash(&mut self, key: &str, field: &str) -> Result<bool, String>

删除哈希指定key的字段

Source

fn get_hash_values(&mut self, key: &str) -> Result<JsonValue, String>

获取key下所有的value

Implementors§