Bug: [REFACTOR] remove `deref` impl on `Cache` type



Currently `Cache` is a type having inner value as `MokaCache`.
```
pub struct Cache {
    inner: MokaCache<String, Arc<dyn Cacheable>>,
}
```

There's a deref impl for this type which returns the inner `MokaCache`. We should instead have custom methods on `Cache` which calls the `MokaCache` methods instead of deref doing the job. There's already custom methods available on `Cache`. Invoke these method instead of calling it on the deref of `Cache`.
diff --git a/crates/router/src/db/cache.rs b/crates/router/src/db/cache.rs
index d9db13dde80..ba0aae55e89 100644
--- a/crates/router/src/db/cache.rs
+++ b/crates/router/src/db/cache.rs
@@ -88,7 +88,7 @@ where
     Fut: futures::Future<Output = CustomResult<T, errors::StorageError>> + Send,
 {
     let data = fun().await?;
-    in_memory.async_map(|cache| cache.invalidate(key)).await;
+    in_memory.async_map(|cache| cache.remove(key)).await;
 
     let redis_conn = store
         .get_redis_conn()
diff --git a/crates/router/tests/cache.rs b/crates/router/tests/cache.rs
index 040e0dddf97..c6eef06db7b 100644
--- a/crates/router/tests/cache.rs
+++ b/crates/router/tests/cache.rs
@@ -50,8 +50,14 @@ async fn invalidate_existing_cache_success() {
     let response_body = response.body().await;
     println!("invalidate Cache: {response:?} : {response_body:?}");
     assert_eq!(response.status(), awc::http::StatusCode::OK);
-    assert!(cache::CONFIG_CACHE.get(&cache_key).await.is_none());
-    assert!(cache::ACCOUNTS_CACHE.get(&cache_key).await.is_none());
+    assert!(cache::CONFIG_CACHE
+        .get_val::<String>(&cache_key)
+        .await
+        .is_none());
+    assert!(cache::ACCOUNTS_CACHE
+        .get_val::<String>(&cache_key)
+        .await
+        .is_none());
 }
 
 #[actix_web::test]
diff --git a/crates/storage_impl/src/redis/cache.rs b/crates/storage_impl/src/redis/cache.rs
index dc2a2225dc9..4cd2fc0c504 100644
--- a/crates/storage_impl/src/redis/cache.rs
+++ b/crates/storage_impl/src/redis/cache.rs
@@ -94,13 +94,6 @@ pub struct Cache {
     inner: MokaCache<String, Arc<dyn Cacheable>>,
 }
 
-impl std::ops::Deref for Cache {
-    type Target = MokaCache<String, Arc<dyn Cacheable>>;
-    fn deref(&self) -> &Self::Target {
-        &self.inner
-    }
-}
-
 impl Cache {
     /// With given `time_to_live` and `time_to_idle` creates a moka cache.
     ///
@@ -122,16 +115,16 @@ impl Cache {
     }
 
     pub async fn push<T: Cacheable>(&self, key: String, val: T) {
-        self.insert(key, Arc::new(val)).await;
+        self.inner.insert(key, Arc::new(val)).await;
     }
 
     pub async fn get_val<T: Clone + Cacheable>(&self, key: &str) -> Option<T> {
-        let val = self.get(key).await?;
+        let val = self.inner.get(key).await?;
         (*val).as_any().downcast_ref::<T>().cloned()
     }
 
     pub async fn remove(&self, key: &str) {
-        self.invalidate(key).await;
+        self.inner.invalidate(key).await;
     }
 }
 
@@ -208,7 +201,7 @@ where
     Fut: futures::Future<Output = CustomResult<T, StorageError>> + Send,
 {
     let data = fun().await?;
-    in_memory.async_map(|cache| cache.invalidate(key)).await;
+    in_memory.async_map(|cache| cache.remove(key)).await;
 
     let redis_conn = store
         .get_redis_conn()
diff --git a/crates/storage_impl/src/redis/pub_sub.rs b/crates/storage_impl/src/redis/pub_sub.rs
index 349d1872d2a..2922dbcadba 100644
--- a/crates/storage_impl/src/redis/pub_sub.rs
+++ b/crates/storage_impl/src/redis/pub_sub.rs
@@ -60,16 +60,16 @@ impl PubSubInterface for redis_interface::RedisConnectionPool {
 
             let key = match key {
                 CacheKind::Config(key) => {
-                    CONFIG_CACHE.invalidate(key.as_ref()).await;
+                    CONFIG_CACHE.remove(key.as_ref()).await;
                     key
                 }
                 CacheKind::Accounts(key) => {
-                    ACCOUNTS_CACHE.invalidate(key.as_ref()).await;
+                    ACCOUNTS_CACHE.remove(key.as_ref()).await;
                     key
                 }
                 CacheKind::All(key) => {
-                    CONFIG_CACHE.invalidate(key.as_ref()).await;
-                    ACCOUNTS_CACHE.invalidate(key.as_ref()).await;
+                    CONFIG_CACHE.remove(key.as_ref()).await;
+                    ACCOUNTS_CACHE.remove(key.as_ref()).await;
                     key
                 }
             };

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Currently `Cache` is a type having inner value as `MokaCache`.
```
pub struct Cache {
    inner: MokaCache<String, Arc<dyn Cacheable>>,
}
```

There's a deref impl on this type which returns the inner `MokaCache`. We should instead have custom methods on `Cache` which calls the `MokaCache` methods instead of deref doing the job. There's already custom methods available on `Cache`. This PR refactors it to invoke these methods instead of calling it on the deref of `Cache`.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
Basic sanity tests should suffice

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
