pub struct HashManager { /* private fields */ }Expand description
Hash data structure interface (Redis-compatible)
Hash is a field-value map, ideal for storing objects.
Implementations§
Source§impl HashManager
impl HashManager
Sourcepub async fn get_all<K>(&self, key: K) -> Result<HashMap<String, String>>
pub async fn get_all<K>(&self, key: K) -> Result<HashMap<String, String>>
Get all fields and values from hash
Sourcepub async fn exists<K, F>(&self, key: K, field: F) -> Result<bool>
pub async fn exists<K, F>(&self, key: K, field: F) -> Result<bool>
Check if field exists in hash
Sourcepub async fn mset<K>(
&self,
key: K,
fields: HashMap<String, String>,
) -> Result<bool>
pub async fn mset<K>( &self, key: K, fields: HashMap<String, String>, ) -> Result<bool>
Set multiple fields in hash
Supports both HashMap format (backward compatible) and array format (Redis-compatible)
§Example
// HashMap format (backward compatible)
let mut fields = HashMap::new();
fields.insert("name".to_string(), "Alice".to_string());
fields.insert("age".to_string(), "30".to_string());
client.hash().mset("user:1", fields).await?;Sourcepub async fn mset_array<K>(
&self,
key: K,
fields: Vec<(String, String)>,
) -> Result<bool>
pub async fn mset_array<K>( &self, key: K, fields: Vec<(String, String)>, ) -> Result<bool>
Set multiple fields in hash using array format (Redis-compatible)
§Example
let fields = vec![
("name".to_string(), "Alice".to_string()),
("age".to_string(), "30".to_string()),
];
client.hash().mset_array("user:1", fields).await?;Sourcepub async fn mget<K>(
&self,
key: K,
fields: Vec<String>,
) -> Result<HashMap<String, Option<String>>>
pub async fn mget<K>( &self, key: K, fields: Vec<String>, ) -> Result<HashMap<String, Option<String>>>
Get multiple fields from hash
Sourcepub async fn incr_by<K, F>(
&self,
key: K,
field: F,
increment: i64,
) -> Result<i64>
pub async fn incr_by<K, F>( &self, key: K, field: F, increment: i64, ) -> Result<i64>
Increment field value by integer
Sourcepub async fn incr_by_float<K, F>(
&self,
key: K,
field: F,
increment: f64,
) -> Result<f64>
pub async fn incr_by_float<K, F>( &self, key: K, field: F, increment: f64, ) -> Result<f64>
Increment field value by float
Trait Implementations§
Source§impl Clone for HashManager
impl Clone for HashManager
Source§fn clone(&self) -> HashManager
fn clone(&self) -> HashManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HashManager
impl !RefUnwindSafe for HashManager
impl Send for HashManager
impl Sync for HashManager
impl Unpin for HashManager
impl UnsafeUnpin for HashManager
impl !UnwindSafe for HashManager
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