fix: Use hsetnx for setting ephemeral key (#278)

This commit is contained in:
Kartikeya Hegde
2023-01-05 13:52:44 +05:30
committed by GitHub
parent 09c745f92f
commit 27b808bdd2
2 changed files with 39 additions and 24 deletions

View File

@ -246,6 +246,25 @@ impl super::RedisConnectionPool {
.await
}
#[instrument(level = "DEBUG", skip(self))]
pub async fn serialize_and_set_multiple_hash_field_if_not_exist<V>(
&self,
kv: &[(&str, V)],
field: &str,
) -> CustomResult<Vec<HsetnxReply>, errors::RedisError>
where
V: serde::Serialize + Debug,
{
let mut hsetnx: Vec<HsetnxReply> = Vec::with_capacity(kv.len());
for (key, val) in kv {
hsetnx.push(
self.serialize_and_set_hash_field_if_not_exist(key, field, val)
.await?,
);
}
Ok(hsetnx)
}
#[instrument(level = "DEBUG", skip(self))]
pub async fn hscan(
&self,