WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/09/2020 07:45:27 PM (20 months ago)
Author:
whyisjake
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/cache.php

    r47197 r47938  
    128128
    129129/**
     130 * Gets multiple values from cache in one call.
     131 *
     132 * @since 5.5.0
     133 * @see WP_Object_Cache::get_multiple()
     134 *
     135 * @param array       $keys   Array of keys to get from group.
     136 * @param string      $group  Optional. Where the cache contents are grouped. Default empty.
     137 * @param bool        $force  Optional. Whether to force an update of the local cache from the persistent
     138 *                            cache. Default false.
     139 * @return array|bool Array of values.
     140 */
     141function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
     142    global $wp_object_cache;
     143
     144    return $wp_object_cache->get_multiple( $keys, $group, $force );
     145}
     146
     147/**
    130148 * Increment numeric cache item's value
    131149 *
Note: See TracChangeset for help on using the changeset viewer.