mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
Refactor(core): Inclusion of constraint graph for merchant Payment Method list (#4626)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: shashank_attarde <shashank.attarde@juspay.in>
This commit is contained in:
@ -27,6 +27,9 @@ const ROUTING_CACHE_PREFIX: &str = "routing";
|
||||
/// Prefix for kgraph cache key
|
||||
const CGRAPH_CACHE_PREFIX: &str = "cgraph";
|
||||
|
||||
/// Prefix for PM Filter cgraph cache key
|
||||
const PM_FILTERS_CGRAPH_CACHE_PREFIX: &str = "pm_filters_cgraph";
|
||||
|
||||
/// Prefix for all kinds of cache key
|
||||
const ALL_CACHE_PREFIX: &str = "all_cache_kind";
|
||||
|
||||
@ -54,6 +57,10 @@ pub static ROUTING_CACHE: Lazy<Cache> =
|
||||
pub static CGRAPH_CACHE: Lazy<Cache> =
|
||||
Lazy::new(|| Cache::new(CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
|
||||
|
||||
/// PM Filter CGraph Cache
|
||||
pub static PM_FILTERS_CGRAPH_CACHE: Lazy<Cache> =
|
||||
Lazy::new(|| Cache::new(CACHE_TTL, CACHE_TTI, Some(MAX_CAPACITY)));
|
||||
|
||||
/// Trait which defines the behaviour of types that's gonna be stored in Cache
|
||||
pub trait Cacheable: Any + Send + Sync + DynClone {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
@ -64,6 +71,7 @@ pub enum CacheKind<'a> {
|
||||
Accounts(Cow<'a, str>),
|
||||
Routing(Cow<'a, str>),
|
||||
CGraph(Cow<'a, str>),
|
||||
PmFiltersCGraph(Cow<'a, str>),
|
||||
All(Cow<'a, str>),
|
||||
}
|
||||
|
||||
@ -74,6 +82,7 @@ impl<'a> From<CacheKind<'a>> for RedisValue {
|
||||
CacheKind::Accounts(s) => format!("{ACCOUNTS_CACHE_PREFIX},{s}"),
|
||||
CacheKind::Routing(s) => format!("{ROUTING_CACHE_PREFIX},{s}"),
|
||||
CacheKind::CGraph(s) => format!("{CGRAPH_CACHE_PREFIX},{s}"),
|
||||
CacheKind::PmFiltersCGraph(s) => format!("{PM_FILTERS_CGRAPH_CACHE_PREFIX},{s}"),
|
||||
CacheKind::All(s) => format!("{ALL_CACHE_PREFIX},{s}"),
|
||||
};
|
||||
Self::from_string(value)
|
||||
@ -93,6 +102,9 @@ impl<'a> TryFrom<RedisValue> for CacheKind<'a> {
|
||||
CONFIG_CACHE_PREFIX => Ok(Self::Config(Cow::Owned(split.1.to_string()))),
|
||||
ROUTING_CACHE_PREFIX => Ok(Self::Routing(Cow::Owned(split.1.to_string()))),
|
||||
CGRAPH_CACHE_PREFIX => Ok(Self::CGraph(Cow::Owned(split.1.to_string()))),
|
||||
PM_FILTERS_CGRAPH_CACHE_PREFIX => {
|
||||
Ok(Self::PmFiltersCGraph(Cow::Owned(split.1.to_string())))
|
||||
}
|
||||
ALL_CACHE_PREFIX => Ok(Self::All(Cow::Owned(split.1.to_string()))),
|
||||
_ => Err(validation_err.into()),
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ use error_stack::ResultExt;
|
||||
use redis_interface::{errors as redis_errors, PubsubInterface, RedisValue};
|
||||
use router_env::logger;
|
||||
|
||||
use crate::redis::cache::{CacheKind, ACCOUNTS_CACHE, CGRAPH_CACHE, CONFIG_CACHE, ROUTING_CACHE};
|
||||
use crate::redis::cache::{
|
||||
CacheKind, ACCOUNTS_CACHE, CGRAPH_CACHE, CONFIG_CACHE, PM_FILTERS_CGRAPH_CACHE, ROUTING_CACHE,
|
||||
};
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait PubSubInterface {
|
||||
@ -71,6 +73,10 @@ impl PubSubInterface for redis_interface::RedisConnectionPool {
|
||||
CGRAPH_CACHE.remove(key.as_ref()).await;
|
||||
key
|
||||
}
|
||||
CacheKind::PmFiltersCGraph(key) => {
|
||||
PM_FILTERS_CGRAPH_CACHE.remove(key.as_ref()).await;
|
||||
key
|
||||
}
|
||||
CacheKind::Routing(key) => {
|
||||
ROUTING_CACHE.remove(key.as_ref()).await;
|
||||
key
|
||||
@ -79,6 +85,7 @@ impl PubSubInterface for redis_interface::RedisConnectionPool {
|
||||
CONFIG_CACHE.remove(key.as_ref()).await;
|
||||
ACCOUNTS_CACHE.remove(key.as_ref()).await;
|
||||
CGRAPH_CACHE.remove(key.as_ref()).await;
|
||||
PM_FILTERS_CGRAPH_CACHE.remove(key.as_ref()).await;
|
||||
ROUTING_CACHE.remove(key.as_ref()).await;
|
||||
key
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user