-
Notifications
You must be signed in to change notification settings - Fork 216
Use database cache for all customer payment methods #4570
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
base: develop
Are you sure you want to change the base?
Use database cache for all customer payment methods #4570
Conversation
…ment_method() to use get_all_payment_methods()
…tion_payment_method() to use get_all_payment_methods()" This reverts commit c622d76.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR transitions the customer payment methods caching system from WordPress transients to a custom database cache implementation. It specifically updates the caching mechanism for "all payment methods" functionality to use WC_Stripe_Database_Cache
instead of built-in WordPress transients, building on changes from a related PR.
Key changes:
- Replaces WordPress transient functions with
WC_Stripe_Database_Cache
methods for all payment methods caching - Introduces a new cache prefix constant for consistency
- Updates documentation to reflect the caching improvements
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
includes/class-wc-stripe-customer.php | Implements database cache for all payment methods instead of transients |
readme.txt | Adds changelog entry for caching improvements |
changelog.txt | Documents the caching enhancement as a tweak |
@@ -15,6 +15,11 @@ class WC_Stripe_Customer { | |||
*/ | |||
const PAYMENT_METHODS_TRANSIENT_KEY = 'stripe_payment_methods_'; | |||
|
|||
/** | |||
* Cache prefix for all saved payment methods per customer.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extra period at the end of the comment. It should be 'per customer.'
* Cache prefix for all saved payment methods per customer.. | |
* Cache prefix for all saved payment methods per customer. |
Copilot uses AI. Check for mistakes.
@@ -940,7 +945,7 @@ public function clear_cache( $payment_method_id = null ) { | |||
foreach ( self::STRIPE_PAYMENT_METHODS as $payment_method_type ) { | |||
delete_transient( self::PAYMENT_METHODS_TRANSIENT_KEY . $payment_method_type . $this->get_id() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clear_cache method has inconsistent caching mechanisms - it still uses delete_transient for individual payment method types but WC_Stripe_Database_Cache::delete for all payment methods. Consider updating all cache clearing to use the same mechanism for consistency.
delete_transient( self::PAYMENT_METHODS_TRANSIENT_KEY . $payment_method_type . $this->get_id() ); | |
WC_Stripe_Database_Cache::delete( self::PAYMENT_METHODS_TRANSIENT_KEY . $payment_method_type . $this->get_id() ); |
Copilot uses AI. Check for mistakes.
Related to #4567
Changes proposed in this Pull Request:
As per the discussion in #4567, this PR builds on the code from that PR to use
WC_Stripe_Database_Cache
instead of built-in WordPress transients.I've put this PR together so we can quickly absorb these changes into the main PR if needed.
Testing instructions
The best approach will be to follow the testing instructions from #4567.
Changelog entry
Changelog Entry Comment
Comment
Post merge