pub trait CacheBase {
Show 52 methods
// Required methods
fn db(&mut self, db: i8) -> &mut Self;
fn key_exists(&mut self, key: &str) -> Result<bool, String>;
fn key_del(&mut self, key: &str) -> Result<bool, String>;
fn key_ttl(&mut self, key: &str) -> Result<i64, String>;
fn key_set_expireat(
&mut self,
key: &str,
timestamp: i64,
) -> Result<bool, String>;
fn key_set_seconds(&mut self, key: &str, s: i64) -> Result<bool, String>;
fn key_del_expire(&mut self, key: &str) -> Result<bool, String>;
fn key_query(&mut self, key: &str) -> Result<JsonValue, 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 set_add(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>;
fn set_count(&mut self, key: &str) -> Result<usize, 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_get_sinter(&mut self, keys: Vec<&str>) -> Result<JsonValue, String>;
fn set_get_sunion(&mut self, keys: Vec<&str>) -> Result<JsonValue, String>;
fn list_add(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>;
fn list_del(&mut self, key: &str, value: JsonValue) -> Result<bool, String>;
fn list_lpush(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>;
fn list_rpush(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>;
fn list_lpop(
&mut self,
key: &str,
count: usize,
) -> Result<Vec<JsonValue>, String>;
fn list_rpop(
&mut self,
key: &str,
count: usize,
) -> Result<Vec<JsonValue>, String>;
fn list_len(&mut self, key: &str) -> Result<usize, String>;
fn list_range(
&mut self,
key: &str,
start: isize,
stop: isize,
) -> Result<Vec<JsonValue>, String>;
fn list_all(&mut self, key: &str) -> Result<Vec<JsonValue>, String>;
fn list_get(&mut self, key: &str, index: isize) -> Result<JsonValue, String>;
fn list_trim(
&mut self,
key: &str,
start: isize,
stop: isize,
) -> Result<bool, String>;
fn list_set(
&mut self,
key: &str,
index: isize,
value: JsonValue,
) -> Result<bool, String>;
fn list_remove(
&mut self,
key: &str,
value: JsonValue,
count: isize,
) -> Result<isize, String>;
fn hash_get(&mut self, key: &str) -> Result<JsonValue, String>;
fn hash_add(
&mut self,
key: &str,
field: &str,
value: JsonValue,
) -> Result<bool, String>;
fn hash_get_field_value(
&mut self,
key: &str,
field: &str,
) -> Result<JsonValue, String>;
fn hash_get_fields(&mut self, key: &str) -> Result<JsonValue, String>;
fn hash_delete(&mut self, key: &str, field: &str) -> Result<bool, String>;
fn hash_get_values(&mut self, key: &str) -> Result<JsonValue, String>;
fn geo_add(
&mut self,
key: &str,
longitude: f64,
latitude: f64,
value: JsonValue,
) -> Result<bool, String>;
fn geo_get(
&mut self,
key: &str,
value: JsonValue,
) -> Result<JsonValue, String>;
fn geo_dist(
&mut self,
key: &str,
value1: JsonValue,
value2: JsonValue,
) -> Result<JsonValue, String>;
fn geo_radius(
&mut self,
key: &str,
value: JsonValue,
radius: &str,
) -> Result<JsonValue, String>;
fn stream_add(
&mut self,
key: &str,
msg_id: &str,
field: &str,
value: JsonValue,
) -> Result<String, String>;
fn stream_count(&mut self, key: &str) -> Result<usize, String>;
fn stream_get(&mut self, key: &str) -> Result<JsonValue, String>;
fn stream_del(&mut self, key: &str, id: &str) -> Result<bool, String>;
fn stream_group_create(
&mut self,
key: &str,
group: &str,
) -> Result<bool, String>;
fn stream_group_add_user(
&mut self,
key: &str,
group: &str,
user: &str,
) -> Result<bool, String>;
fn stream_group_del_user(
&mut self,
key: &str,
group: &str,
user: &str,
) -> Result<bool, String>;
fn stream_group_del(
&mut self,
key: &str,
group: &str,
) -> Result<bool, String>;
fn stream_group_msg(
&mut self,
key: &str,
group: &str,
user: &str,
) -> Result<JsonValue, String>;
fn stream_get_group(
&mut self,
key: &str,
group: &str,
) -> Result<bool, String>;
fn stream_get_stream(&mut self, key: &str) -> Result<JsonValue, String>;
fn subscribe(
&mut self,
key: &str,
tx: Sender<JsonValue>,
) -> Result<(), String>;
fn publish(&mut self, key: &str, value: JsonValue) -> Result<bool, String>;
}Required Methods§
Sourcefn key_set_expireat(
&mut self,
key: &str,
timestamp: i64,
) -> Result<bool, String>
fn key_set_expireat( &mut self, key: &str, timestamp: i64, ) -> Result<bool, String>
键 设置到期时间
- key 键
- timestamp 到期时间戳 10位
Sourcefn add(
&mut self,
key: &str,
value: JsonValue,
expiration_date: u64,
) -> Result<bool, String>
fn add( &mut self, key: &str, value: JsonValue, expiration_date: u64, ) -> Result<bool, String>
设置缓存
- expiration_date 过期时间 s 秒
Sourcefn set_add(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>
fn set_add( &mut self, key: &str, value: JsonValue, expiry_s: i64, ) -> Result<bool, String>
集合 添加
Sourcefn list_add(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>
fn list_add( &mut self, key: &str, value: JsonValue, expiry_s: i64, ) -> Result<bool, String>
列表 添加
Sourcefn list_lpush(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>
fn list_lpush( &mut self, key: &str, value: JsonValue, expiry_s: i64, ) -> Result<bool, String>
从列表左侧添加元素
Sourcefn list_rpush(
&mut self,
key: &str,
value: JsonValue,
expiry_s: i64,
) -> Result<bool, String>
fn list_rpush( &mut self, key: &str, value: JsonValue, expiry_s: i64, ) -> Result<bool, String>
从列表右侧添加元素
Sourcefn list_lpop(
&mut self,
key: &str,
count: usize,
) -> Result<Vec<JsonValue>, String>
fn list_lpop( &mut self, key: &str, count: usize, ) -> Result<Vec<JsonValue>, String>
从列表左侧弹出元素 count: 0 = 弹出1个(兼容旧版),>0 = 弹出指定数量
Sourcefn list_rpop(
&mut self,
key: &str,
count: usize,
) -> Result<Vec<JsonValue>, String>
fn list_rpop( &mut self, key: &str, count: usize, ) -> Result<Vec<JsonValue>, String>
从列表右侧弹出元素
Sourcefn list_range(
&mut self,
key: &str,
start: isize,
stop: isize,
) -> Result<Vec<JsonValue>, String>
fn list_range( &mut self, key: &str, start: isize, stop: isize, ) -> Result<Vec<JsonValue>, String>
获取列表指定范围的元素
Sourcefn list_trim(
&mut self,
key: &str,
start: isize,
stop: isize,
) -> Result<bool, String>
fn list_trim( &mut self, key: &str, start: isize, stop: isize, ) -> Result<bool, String>
修剪列表,只保留指定范围内的元素
Sourcefn list_set(
&mut self,
key: &str,
index: isize,
value: JsonValue,
) -> Result<bool, String>
fn list_set( &mut self, key: &str, index: isize, value: JsonValue, ) -> Result<bool, String>
设置指定索引位置的元素值
Sourcefn list_remove(
&mut self,
key: &str,
value: JsonValue,
count: isize,
) -> Result<isize, String>
fn list_remove( &mut self, key: &str, value: JsonValue, count: isize, ) -> Result<isize, String>
删除列表中指定值的元素(count=0表示删除所有匹配项)
Sourcefn hash_add(
&mut self,
key: &str,
field: &str,
value: JsonValue,
) -> Result<bool, String>
fn hash_add( &mut self, key: &str, field: &str, value: JsonValue, ) -> Result<bool, String>
添加哈希
Sourcefn hash_get_field_value(
&mut self,
key: &str,
field: &str,
) -> Result<JsonValue, String>
fn hash_get_field_value( &mut self, key: &str, field: &str, ) -> Result<JsonValue, String>
获取哈希指定key的字段值
Sourcefn geo_add(
&mut self,
key: &str,
longitude: f64,
latitude: f64,
value: JsonValue,
) -> Result<bool, String>
fn geo_add( &mut self, key: &str, longitude: f64, latitude: f64, value: JsonValue, ) -> Result<bool, String>
地理 添加地理位置
Sourcefn geo_dist(
&mut self,
key: &str,
value1: JsonValue,
value2: JsonValue,
) -> Result<JsonValue, String>
fn geo_dist( &mut self, key: &str, value1: JsonValue, value2: JsonValue, ) -> Result<JsonValue, String>
地理 获取两地之间的距离地理位置
Sourcefn geo_radius(
&mut self,
key: &str,
value: JsonValue,
radius: &str,
) -> Result<JsonValue, String>
fn geo_radius( &mut self, key: &str, value: JsonValue, radius: &str, ) -> Result<JsonValue, String>
地理 以给定的经纬度为中心, 返回键包含的位置元素当中, 与中心的距离不超过给定最大距离的所有位置元素
Sourcefn stream_add(
&mut self,
key: &str,
msg_id: &str,
field: &str,
value: JsonValue,
) -> Result<String, String>
fn stream_add( &mut self, key: &str, msg_id: &str, field: &str, value: JsonValue, ) -> Result<String, String>
设置消息队列
fn stream_group_add_user( &mut self, key: &str, group: &str, user: &str, ) -> Result<bool, String>
fn stream_group_del_user( &mut self, key: &str, group: &str, user: &str, ) -> Result<bool, String>
Sourcefn stream_group_msg(
&mut self,
key: &str,
group: &str,
user: &str,
) -> Result<JsonValue, String>
fn stream_group_msg( &mut self, key: &str, group: &str, user: &str, ) -> Result<JsonValue, String>
删除 消费者
fn stream_get_stream(&mut self, key: &str) -> Result<JsonValue, String>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.