#54574 closed enhancement (fixed)
Add wp_cache_*_multiple function
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Cache API | Keywords: | has-patch has-unit-tests needs-docs has-dev-note |
Focuses: | performance | Cc: |
Description
The wp_cache_get_multiple
function was added in #20875. This allow for multiple cache keys be collected in one request. To complete the api, we should add the full CRUD functions. So
wp_cache_add_multiple
wp_cache_delete_multiple
wp_cache_update_multiple
In core these would just be wrapper for core functions to allow multiple keys to passed in one function call. But would allow object cache plugin developers to implement them if their backend support it.
Change History (23)
#2
@
2 years ago
One the major things to need to decide to function signature. Here are some function signatures to consider.
function wp_cache_multiple_set( array $keys, array $values, array $groups )
function wp_cache_multiple_set( array $data )
$data = array( array( 'key' => 'test', 'value' => 'tool', 'group' => 'test'));
function wp_cache_multiple_set( array $key_value_pair, $group )
#3
follow-up:
↓ 5
@
2 years ago
These functions can be used in the following places.
- update_meta_cache
- update_post_cache
- update_term_cache
- clean_object_term_cache
- clean_term_cache
- wp_delete_post
This ticket was mentioned in PR #2018 on WordPress/wordpress-develop by spacedmonkey.
2 years ago
#4
- Keywords has-patch added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/54574
#5
in reply to:
↑ 3
@
23 months ago
This brings up my question: can we leverage these new functions in core already?
Is the plan to update the existing cache functions to accept multiple keys? Should these new functions be "private" or internal (start with _
)?
Replying to spacedmonkey:
These functions can be used in the following places.
- update_meta_cache
- update_post_cache
- update_term_cache
- clean_object_term_cache
- clean_term_cache
- wp_delete_post
#6
@
22 months ago
- Keywords has-unit-tests added
- Milestone changed from Awaiting Review to 6.0
- Owner set to spacedmonkey
- Status changed from new to assigned
#7
@
22 months ago
Is the plan to update the existing cache functions to accept multiple keys? Should these new functions be "private" or internal (start with _)?
Good flag @adamsilverstein and YES! I have created a follow on ticket at #55029
tillkruss commented on PR #2018:
22 months ago
#8
@spacedmonkey This looks great. I've got one thought, what about atomicity?
Should we be adding an optional parameter to indicate that we'd want the call to be atomic? Whether the cache implementation supports or is able to, it is up to it.
tillkruss commented on PR #2018:
22 months ago
#9
@spacedmonkey This looks great. I've got one thought, what about atomicity?
Should we be adding an optional parameter to indicate that we'd want the call to be atomic? Whether the cache implementation supports or is able to, it is up to it.
spacedmonkey commented on PR #2018:
22 months ago
#10
CC @mitogh
spacedmonkey commented on PR #2018:
22 months ago
#12
Merged
#14
@
22 months ago
This PR is ready for re-review.
This comment is for https://core.trac.wordpress.org/ticket/55029, right?
One of the engineers at Pagely was just asking me about batch API methods for cache operations, so 👍