mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat: Impelement redis cache for MCA fetch and update (#515)
This commit is contained in:
@ -154,15 +154,26 @@ impl MerchantConnectorAccountInterface for Store {
|
|||||||
merchant_id: &str,
|
merchant_id: &str,
|
||||||
merchant_connector_id: &str,
|
merchant_connector_id: &str,
|
||||||
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
|
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
|
||||||
let conn = pg_connection(&self.master_pool).await;
|
let find_call = || async {
|
||||||
storage::MerchantConnectorAccount::find_by_merchant_id_merchant_connector_id(
|
let conn = pg_connection(&self.master_pool).await;
|
||||||
&conn,
|
storage::MerchantConnectorAccount::find_by_merchant_id_merchant_connector_id(
|
||||||
merchant_id,
|
&conn,
|
||||||
merchant_connector_id,
|
merchant_id,
|
||||||
)
|
merchant_connector_id,
|
||||||
.await
|
)
|
||||||
.map_err(Into::into)
|
.await
|
||||||
.into_report()
|
.map_err(Into::into)
|
||||||
|
.into_report()
|
||||||
|
};
|
||||||
|
#[cfg(not(feature = "accounts_cache"))]
|
||||||
|
{
|
||||||
|
find_call().await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "accounts_cache")]
|
||||||
|
{
|
||||||
|
super::cache::get_or_populate_cache(self, merchant_connector_id, find_call).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn insert_merchant_connector_account(
|
async fn insert_merchant_connector_account(
|
||||||
@ -189,11 +200,24 @@ impl MerchantConnectorAccountInterface for Store {
|
|||||||
this: storage::MerchantConnectorAccount,
|
this: storage::MerchantConnectorAccount,
|
||||||
merchant_connector_account: storage::MerchantConnectorAccountUpdate,
|
merchant_connector_account: storage::MerchantConnectorAccountUpdate,
|
||||||
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
|
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
|
||||||
let conn = pg_connection(&self.master_pool).await;
|
let _merchant_connector_id = this.merchant_connector_id.clone();
|
||||||
this.update(&conn, merchant_connector_account)
|
let update_call = || async {
|
||||||
.await
|
let conn = pg_connection(&self.master_pool).await;
|
||||||
.map_err(Into::into)
|
this.update(&conn, merchant_connector_account)
|
||||||
.into_report()
|
.await
|
||||||
|
.map_err(Into::into)
|
||||||
|
.into_report()
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "accounts_cache")]
|
||||||
|
{
|
||||||
|
super::cache::redact_cache(self, &_merchant_connector_id, update_call).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "accounts_cache"))]
|
||||||
|
{
|
||||||
|
update_call().await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(
|
async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(
|
||||||
|
|||||||
@ -3,7 +3,17 @@ use masking::Secret;
|
|||||||
|
|
||||||
use crate::{enums as storage_enums, schema::merchant_connector_account};
|
use crate::{enums as storage_enums, schema::merchant_connector_account};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, router_derive::DebugAsDisplay)]
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
serde::Serialize,
|
||||||
|
serde::Deserialize,
|
||||||
|
PartialEq,
|
||||||
|
Identifiable,
|
||||||
|
Queryable,
|
||||||
|
router_derive::DebugAsDisplay,
|
||||||
|
)]
|
||||||
#[diesel(table_name = merchant_connector_account)]
|
#[diesel(table_name = merchant_connector_account)]
|
||||||
pub struct MerchantConnectorAccount {
|
pub struct MerchantConnectorAccount {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
|
|||||||
Reference in New Issue
Block a user