Make WordPress Core


Ignore:
Timestamp:
02/11/2022 06:50:08 PM (3 years ago)
Author:
spacedmonkey
Message:

Cache: Use wp_cache_*_multiple() in core functions.

Implement the wp_cache_add_multiplewp_cache_set_multiple and wp_cache_delete_multiple in a number of core functions after they were introduced in [52700]

Props: spacedmonkey, adamsilverstein, flixos90, mitogh.
Fixes: #55029.

File:
1 edited

Legend:

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

    r52140 r52707  
    497497
    498498    if ( $delete_all ) {
    499         foreach ( (array) $object_ids as $o_id ) {
    500             wp_cache_delete( $o_id, $meta_type . '_meta' );
    501         }
     499        $data = (array) $object_ids;
    502500    } else {
    503         wp_cache_delete( $object_id, $meta_type . '_meta' );
    504     }
     501        $data = array( $object_id );
     502    }
     503    wp_cache_delete_multiple( $data, $meta_type . '_meta' );
    505504
    506505    /**
     
    11921191    }
    11931192
     1193    $data = array();
    11941194    foreach ( $non_cached_ids as $id ) {
    11951195        if ( ! isset( $cache[ $id ] ) ) {
    11961196            $cache[ $id ] = array();
    11971197        }
    1198         wp_cache_add( $id, $cache[ $id ], $cache_key );
    1199     }
     1198        $data[ $id ] = $cache[ $id ];
     1199    }
     1200    wp_cache_add_multiple( $data, $cache_key );
    12001201
    12011202    return $cache;
Note: See TracChangeset for help on using the changeset viewer.