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

Implement the `wp_cache_add_multiple`, `wp_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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52707 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonny Harris
2022-02-11 18:50:08 +00:00
parent 5d7297d031
commit deafd1193c
8 changed files with 55 additions and 36 deletions

View File

@@ -496,12 +496,11 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $
}
if ( $delete_all ) {
foreach ( (array) $object_ids as $o_id ) {
wp_cache_delete( $o_id, $meta_type . '_meta' );
}
$data = (array) $object_ids;
} else {
wp_cache_delete( $object_id, $meta_type . '_meta' );
$data = array( $object_id );
}
wp_cache_delete_multiple( $data, $meta_type . '_meta' );
/**
* Fires immediately after deleting metadata of a specific type.
@@ -1191,12 +1190,14 @@ function update_meta_cache( $meta_type, $object_ids ) {
}
}
$data = array();
foreach ( $non_cached_ids as $id ) {
if ( ! isset( $cache[ $id ] ) ) {
$cache[ $id ] = array();
}
wp_cache_add( $id, $cache[ $id ], $cache_key );
$data[ $id ] = $cache[ $id ];
}
wp_cache_add_multiple( $data, $cache_key );
return $cache;
}