Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add multiple insert and delete functionality for in-memory cache #2373

Open
2 tasks done
dracarys18 opened this issue Sep 26, 2023 · 13 comments
Open
2 tasks done
Assignees
Labels
A-framework Area: Framework C-feature Category: Feature request or enhancement good first issue Good for newcomers hacktoberfest Issues that are up for grabs for Hacktoberfest participants

Comments

@dracarys18
Copy link
Member

Feature Description

There are few cases where we insert/delete multiple keys in the cache. So add a function where it takes multiple key values and insert and delete it in the cache.

Possible Implementation

struct CacheValues {
	inner: Vec<String>
}

We can have a struct like this and make modify enum CacheKind to accept CacheValues.

enum CacheKind {
	Accounts(CacheValues),
	.....
}

Have you spent some time checking if this feature request has been raised before?

  • I checked and didn't find a similar issue

Have you read the Contributing Guidelines?

Are you willing to submit a PR?

None

@dracarys18 dracarys18 added C-feature Category: Feature request or enhancement S-awaiting-triage Status: New issues that have not been assessed yet labels Sep 26, 2023
@dracarys18 dracarys18 self-assigned this Sep 26, 2023
@dracarys18 dracarys18 added the good first issue Good for newcomers label Sep 26, 2023
@dracarys18 dracarys18 removed their assignment Sep 27, 2023
@rohithsai1904
Copy link

I want to try this.
Can you assign me the issue?

@SanchithHegde
Copy link
Member

Sure @rohithsai1904, I'll assign this to you. Let us know in case you have any questions, on this issue thread or on our Discord server.

@SanchithHegde SanchithHegde added A-framework Area: Framework hacktoberfest Issues that are up for grabs for Hacktoberfest participants and removed S-awaiting-triage Status: New issues that have not been assessed yet labels Oct 1, 2023
@VedantKhairnar
Copy link
Collaborator

Hey @rohithsai1904 ,
Let us know if you face any issues. Happy to help! : )

@agatekartik
Copy link

It would be great if there are more examples with context of uses/use-cases

@dracarys18
Copy link
Member Author

dracarys18 commented Oct 5, 2023

hey @agatekartik you can check this code

#[cfg(feature = "accounts_cache")]
async fn publish_and_redact_merchant_account_cache(
store: &dyn super::StorageInterface,
merchant_account: &storage::MerchantAccount,
) -> CustomResult<(), errors::StorageError> {
super::cache::publish_into_redact_channel(
store,
CacheKind::Accounts(merchant_account.merchant_id.as_str().into()),
)
.await?;
merchant_account
.publishable_key
.as_ref()
.async_map(|pub_key| async {
super::cache::publish_into_redact_channel(store, CacheKind::Accounts(pub_key.into()))
.await
})
.await
.transpose()?;
Ok(())
}

Here we are redacting two keys and making two calls to publish_and_redact function. Instead of it we can just use a single redis connection for redacting this and one call to the function.

@VedantKhairnar
Copy link
Collaborator

Hey @rohithsai1904 ,
Just checking in - are you working on it or shall we consider reassigning it to someone else?

@rohithsai1904
Copy link

rohithsai1904 commented Oct 10, 2023 via email

@VedantKhairnar
Copy link
Collaborator

Sure @rohithsai1904
Take your time, let us know if you need any help. : )

@rohithsai1904
Copy link

rohithsai1904 commented Oct 20, 2023

Is there any documentation or architecture kind of a thing related to the issue?
Im checking this (https://hyperswitch.io/docs) currently

(https://github.com/juspay/hyperswitch/tree/main/docs)Got it...

@SanchithHegde
Copy link
Member

@rohithsai1904 There isn't an architecture doc for the in-memory cache specifically, but I'll provide you some context about how the in-memory cache is used.

We have 3 levels of persistence, the in-memory cache, Redis and a PostgreSQL database, much similar to the memory hierarchy you'd see on a computer (CPU cache, RAM and disk respectively). The database is our persistent storage, with items being temporarily stored in Redis and in-memory cache to decrease read latencies. Among these items being cached, the ones that are not expected to be frequently updated (such as merchant account, merchant key store, API keys, merchant connector accounts) are stored in the in-memory cache. And when an item in the in-memory cache needs to be updated, that item is invalidated (removed) from the cache.

As of now, we have support for inserting items to and deleting items from the in-memory cache one at a time. This issue involves introducing support for inserting and deleting multiple items at once.

Let us know if you have any more questions.

@deepanshu-iiitu
Copy link
Contributor

Hey @rohithsai1904
Just checking in - are you working on it? Do you need help from our side?

@rohithsai1904
Copy link

rohithsai1904 commented Oct 27, 2023

https://github.com/juspay/hyperswitch/blob/main/crates/storage_impl/src/redis/cache.rs
I got that i have to make changes in this file.right?

Correct me if im wrong....is there any other file for in memory cache?... or is this just the redis cache?

@dracarys18
Copy link
Member Author

Yeah you have to make change there @rohithsai1904 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Area: Framework C-feature Category: Feature request or enhancement good first issue Good for newcomers hacktoberfest Issues that are up for grabs for Hacktoberfest participants
Projects
None yet
Development

No branches or pull requests

6 participants