Cache API: Introduce wp_cache_get_multi().

Many caching backend have support for multiple gets in a single request. This brings that support to core, with a compatability fallback that will loop over requests if needed.

Fixes: #20875.
Props: nacin, tollmanz, wonderboymusic, ryan, jeremyfelt, spacedmonkey, boonebgorges, dd32, rmccue, ocean90, jipmoors, johnjamesjacoby, tillkruess, donmhico, davidbaumwald, SergeyBiryukov, whyisjake.



git-svn-id: https://develop.svn.wordpress.org/trunk@47938 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-06-09 19:45:27 +00:00
parent 78d1ab2ed4
commit d4d78e4ae7
5 changed files with 65 additions and 0 deletions

View File

@@ -126,6 +126,24 @@ function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
return $wp_object_cache->get( $key, $group, $force, $found );
}
/**
* Gets multiple values from cache in one call.
*
* @since 5.5.0
* @see WP_Object_Cache::get_multiple()
*
* @param array $keys Array of keys to get from group.
* @param string $group Optional. Where the cache contents are grouped. Default empty.
* @param bool $force Optional. Whether to force an update of the local cache from the persistent
* cache. Default false.
* @return array|bool Array of values.
*/
function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
global $wp_object_cache;
return $wp_object_cache->get_multiple( $keys, $group, $force );
}
/**
* Increment numeric cache item's value
*