mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
db: Added ephemeral key functions (#84)
This commit is contained in:
@ -13,7 +13,7 @@ use fred::{
|
||||
interfaces::{KeysInterface, StreamsInterface},
|
||||
types::{
|
||||
Expiration, FromRedis, MultipleIDs, MultipleKeys, MultipleOrderedPairs, MultipleStrings,
|
||||
RedisValue, SetOptions, XReadResponse,
|
||||
RedisMap, RedisValue, SetOptions, XReadResponse,
|
||||
},
|
||||
};
|
||||
use router_env::{tracing, tracing::instrument};
|
||||
@ -43,6 +43,18 @@ impl super::RedisConnectionPool {
|
||||
.change_context(errors::RedisError::SetFailed)
|
||||
}
|
||||
|
||||
pub async fn msetnx<V>(&self, value: V) -> CustomResult<u8, errors::RedisError>
|
||||
where
|
||||
V: TryInto<RedisMap> + Debug,
|
||||
V::Error: Into<fred::error::RedisError>,
|
||||
{
|
||||
self.pool
|
||||
.msetnx::<u8, V>(value)
|
||||
.await
|
||||
.into_report()
|
||||
.change_context(errors::RedisError::SetFailed)
|
||||
}
|
||||
|
||||
#[instrument(level = "DEBUG", skip(self))]
|
||||
pub async fn serialize_and_set_key<V>(
|
||||
&self,
|
||||
|
||||
@ -4,6 +4,7 @@ pub mod commands;
|
||||
pub mod errors;
|
||||
pub mod types;
|
||||
|
||||
pub use fred::prelude::*;
|
||||
use router_env::logger;
|
||||
|
||||
pub use self::{commands::*, types::*};
|
||||
|
||||
Reference in New Issue
Block a user