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

Memoize Spree::User#wallet method #3513

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

AlessioRocco
Copy link
Contributor

@AlessioRocco AlessioRocco commented Feb 13, 2020

Description

We are already using memoization on some Spree::Order methods:

and Spree::User#wallet seems a good candidate to memoize.

Without memoization every time someone calls this method a new instance of Spree::Wallet is created but I think we should interact ever with the same instance, It seems logical to me that a user has just one wallet, this way the code reflect the reality and It also improves performance and memory usage.

Checklist:

Add cache to the "Spree::User#wallet" method.
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlessioRocco seems legit, thank you 👍

@kennyadsl
Copy link
Member

@AlessioRocco I don't get why this is legit, can you expand a little bit more. Also, it would be helpful to understand what's wrong with the current version.

@AlessioRocco
Copy link
Contributor Author

@kennyadsl I've updated the description to better explain because I did this change.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alessio!

@kennyadsl kennyadsl merged commit 62250a5 into solidusio:master Feb 25, 2020
@AlessioRocco AlessioRocco deleted the memoize-user-wallet branch March 11, 2020 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants