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/comment.php

    r52332 r52707  
    18841884function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) {
    18851885    if ( 'approved' === $new_status || 'approved' === $old_status ) {
     1886        $data = array();
    18861887        foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
    1887             wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
    1888         }
     1888            $data[] = "lastcommentmodified:$timezone";
     1889        }
     1890        wp_cache_delete_multiple( $data, 'timeinfo' );
    18891891    }
    18901892}
     
    20462048        wp_update_comment_count( $comment_post_ID );
    20472049
     2050        $data = array();
    20482051        foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
    2049             wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
    2050         }
     2052            $data[] = "lastcommentmodified:$timezone";
     2053        }
     2054        wp_cache_delete_multiple( $data, 'timeinfo' );
    20512055    }
    20522056
     
    32213225 */
    32223226function clean_comment_cache( $ids ) {
    3223     foreach ( (array) $ids as $id ) {
    3224         wp_cache_delete( $id, 'comment' );
    3225 
     3227    $comment_ids = (array) $ids;
     3228    wp_cache_delete_multiple( $comment_ids, 'comment' );
     3229    foreach ( $comment_ids as $id ) {
    32263230        /**
    32273231         * Fires immediately after a comment has been removed from the object cache.
     
    32513255 */
    32523256function update_comment_cache( $comments, $update_meta_cache = true ) {
     3257    $data = array();
    32533258    foreach ( (array) $comments as $comment ) {
    3254         wp_cache_add( $comment->comment_ID, $comment, 'comment' );
    3255     }
     3259        $data[ $comment->comment_ID ] = $comment;
     3260    }
     3261    wp_cache_add_multiple( $data, 'comment' );
    32563262
    32573263    if ( $update_meta_cache ) {
Note: See TracChangeset for help on using the changeset viewer.