Make WordPress Core

Changeset 48055


Ignore:
Timestamp:
06/16/2020 06:28:57 AM (5 years ago)
Author:
whyisjake
Message:

Cache API: Add wp_cache_get_multiple() to core functions.

  • update_object_term_cache
  • update_meta_cache
  • _get_non_cached_ids

See [47938].

Fixes #50352.

Props spacedmonkey, tillkruss, lukecavanagh.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

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

    r48054 r48055  
    63606360 */
    63616361function _get_non_cached_ids( $object_ids, $cache_key ) {
    6362     $clean = array();
    6363     foreach ( $object_ids as $id ) {
     6362    $clean        = array();
     6363    $cache_values = wp_cache_get_multiple( $object_ids, $cache_key );
     6364    foreach ( $cache_values as $id => $cache_value ) {
    63646365        $id = (int) $id;
    6365         if ( ! wp_cache_get( $id, $cache_key ) ) {
     6366        if ( ! $cache_value ) {
    63666367            $clean[] = $id;
    63676368        }
  • trunk/src/wp-includes/meta.php

    r47808 r48055  
    927927    }
    928928
    929     $cache_key = $meta_type . '_meta';
    930     $ids       = array();
    931     $cache     = array();
    932     foreach ( $object_ids as $id ) {
    933         $cached_object = wp_cache_get( $id, $cache_key );
     929    $cache_key    = $meta_type . '_meta';
     930    $ids          = array();
     931    $cache        = array();
     932    $cache_values = wp_cache_get_multiple( $object_ids, $cache_key );
     933    foreach ( $cache_values as $id => $cached_object ) {
    934934        if ( false === $cached_object ) {
    935935            $ids[] = $id;
  • trunk/src/wp-includes/taxonomy.php

    r47930 r48055  
    34113411
    34123412    $ids = array();
    3413     foreach ( (array) $object_ids as $id ) {
    3414         foreach ( $taxonomies as $taxonomy ) {
    3415             if ( false === wp_cache_get( $id, "{$taxonomy}_relationships" ) ) {
    3416                 $ids[] = $id;
     3413    foreach ( $taxonomies as $taxonomy ) {
     3414        $cache_values = wp_cache_get_multiple( (array) $object_ids, "{$taxonomy}_relationships" );
     3415        foreach ( $cache_values as $key => $value ) {
     3416            if ( false === $value ) {
     3417                $ids[] = $key;
    34173418                break;
    34183419            }
Note: See TracChangeset for help on using the changeset viewer.