pub struct BitObject {}
Expand description

这个对应redis中的hash, 字段数据量建议在2048个以内,在遍历数据时,性能比[ObjectImp]好 使用一个大的数组把key的值存下,以方便访问全部的field,与[ObjectImp]相比需要维护一个数组,当field数量不多时,性能比较好 所有的key以数组方式存入,有先后关系。如果删除其中的一个field其后的数据,会平移。

数据特点: 有field变动的性能,是O(N),所以数据不能多 读取数据时O(1)

Trait Implementations§

source§

impl<T: WrapDb> Object<T> for BitObject

source§

fn del(&self, t: &T, key: &[u8], field: &[u8]) -> Result<(), RrError>

删除指定的字段,并返回对应的值,如果没有返回None
source§

fn dels(&self, t: &T, key: &[u8], fields: &[&[u8]]) -> Result<LenType, RrError>

返回被成功删除字段的数量,如果字段不存在,也计算在成功删除中
source§

fn exists(&self, t: &T, key: &[u8], field: &[u8]) -> Result<bool, RrError>

true: 表示存在, false: key或field不存在
source§

fn get(&self, t: &T, key: &[u8], field: &[u8]) -> Result<Option<Vec<u8>>, RrError>

source§

fn get_all( &self, t: &T, key: &[u8] ) -> Result<Option<Vec<(Vec<u8>, Vec<u8>)>>, RrError>

返回所有字段与值
source§

fn keys(&self, t: &T, key: &[u8]) -> Result<Option<Vec<Vec<u8>>>, RrError>

返回所有的字段
source§

fn len(&self, t: &T, key: &[u8]) -> Result<Option<LenType>, RrError>

返回字段的数量
source§

fn mget( &self, t: &T, key: &[u8], fields: &[&[u8]] ) -> Result<Vec<Option<Vec<u8>>>, RrError>

返回值与请求顺序一样,如果字段不存在值为None
source§

fn set(&self, t: &T, key: &[u8], field: &[u8], value: &[u8]) -> Result<(), RrError>

source§

fn set_not_exist( &self, t: &T, key: &[u8], field: &[u8], value: &[u8] ) -> Result<i32, RrError>

设置成功,返回 1 。 如果给定字段已经存在且没有操作被执行,返回 0 对应redis的hsetnx
source§

fn set_exist( &self, t: &T, key: &[u8], field: &[u8], value: &[u8] ) -> Result<i32, RrError>

设置成功,返回 1 。 如果给定字段已经存则执行,不存在返回 0
source§

fn vals(&self, t: &T, key: &[u8]) -> Result<Vec<Vec<u8>>, RrError>

一个包含哈希表中所有值的列表。 当 key 不存在时,返回一个空表
source§

fn del_key(&self, t: &T, key: &[u8]) -> Result<(), RrError>

删除指定的key,及所有字段

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.