-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Feature: Add wp_cache_replace_multiple function
#7440
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: trunk
Are you sure you want to change the base?
Feature: Add wp_cache_replace_multiple function
#7440
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Hi @spacedmonkey , can you please take a look into this PR. Thanks. |
apermo
left a comment
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.
WPCS fixed for PHPDoc, otherwise it looks good to me.
Trac Ticket: Core-56060
Overview
wp_cache_replace_multiplefunction, addressing the need to replace multiple cache values only if they already exist. This functionality is essential for scenarios involving multiple caching backends, allowing developers to manage cache data without unintentionally adding new entries.Problem Statement
replace()method does not effectively check for the existence of multiple keys, particularly when the$groupparameter is empty. This limitation can cause issues in managing caches across different backends, especially when updates are needed without creating new entries.Key Features
Conditional Replacement: The function checks if each specified key exists in the cache before attempting to replace its value, ensuring that only existing keys are updated.Batch Processing: It utilizesset_multiple()for efficient bulk updates, minimizing backend calls and improving overall performance.Return Values:The function returns an array of keys that were successfully replaced, providing clear feedback on the updates made.Benefits
Improved Cache Integrity: Prevents the addition of new entries, maintaining the integrity of existing cache data.Performance Efficiency: Reduces unnecessary operations by only updating existing entries.Usability: Enhances developer experience with a straightforward approach to manage cache values.