WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#54574 new enhancement

Add wp_cache_*_multiple function

Reported by: spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Cache API Keywords: has-patch
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 (4)

#1 @tillkruess
7 weeks ago

One of the engineers at Pagely was just asking me about batch API methods for cache operations, so 👍

#2 @spacedmonkey
7 weeks 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 @spacedmonkey
7 weeks 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.


7 weeks ago

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.