mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat: kv for reverse lookup (#2445)
This commit is contained in:
@ -65,6 +65,22 @@ impl super::RedisConnectionPool {
|
||||
.change_context(errors::RedisError::SetFailed)
|
||||
}
|
||||
|
||||
#[instrument(level = "DEBUG", skip(self))]
|
||||
pub async fn serialize_and_set_key_if_not_exist<V>(
|
||||
&self,
|
||||
key: &str,
|
||||
value: V,
|
||||
ttl: Option<i64>,
|
||||
) -> CustomResult<SetnxReply, errors::RedisError>
|
||||
where
|
||||
V: serde::Serialize + Debug,
|
||||
{
|
||||
let serialized = Encode::<V>::encode_to_vec(&value)
|
||||
.change_context(errors::RedisError::JsonSerializationFailed)?;
|
||||
self.set_key_if_not_exists_with_expiry(key, serialized.as_slice(), ttl)
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(level = "DEBUG", skip(self))]
|
||||
pub async fn serialize_and_set_key<V>(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user