mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Cache API: Reorder object cache functions and methods for consistency.
The original order was alphabetical, which became less obvious as newer functions got added, resulting in a somewhat random order. This commits aims to organize the functions and related `WP_Object_Cache` methods in a more predictable order: * `wp_cache_init()` * `wp_cache_add()` * `wp_cache_add_multiple()` * `wp_cache_replace()` * `wp_cache_set()` * `wp_cache_set_multiple()` * `wp_cache_get()` * `wp_cache_get_multiple()` * `wp_cache_delete()` * `wp_cache_delete_multiple()` * `wp_cache_incr()` * `wp_cache_decr()` * `wp_cache_flush()` * `wp_cache_close()` * `wp_cache_add_global_groups()` * `wp_cache_add_non_persistent_groups()` * `wp_cache_switch_to_blog()` * `wp_cache_reset()` Follow-up to [3011], [6543], [7986], [13066], [18580], [21403], [47938], [52700], [52703-52705]. See #54728, #54574. git-svn-id: https://develop.svn.wordpress.org/trunk@52706 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -8,61 +8,6 @@
|
||||
* @subpackage Cache
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'wp_cache_get_multiple' ) ) :
|
||||
/**
|
||||
* Retrieves multiple values from the cache in one call.
|
||||
*
|
||||
* Compat function to mimic wp_cache_get_multiple().
|
||||
*
|
||||
* @ignore
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @see wp_cache_get_multiple()
|
||||
*
|
||||
* @param array $keys Array of keys under which the cache contents are stored.
|
||||
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
||||
* @param bool $force Optional. Whether to force an update of the local cache
|
||||
* from the persistent cache. Default false.
|
||||
* @return array Array of values organized into groups.
|
||||
*/
|
||||
function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
|
||||
$values = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
$values[ $key ] = wp_cache_get( $key, $group, $force );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'wp_cache_delete_multiple' ) ) :
|
||||
/**
|
||||
* Deletes multiple values from the cache in one call.
|
||||
*
|
||||
* Compat function to mimic wp_cache_delete_multiple().
|
||||
*
|
||||
* @ignore
|
||||
* @since 6.0.0
|
||||
*
|
||||
* @see wp_cache_delete_multiple()
|
||||
*
|
||||
* @param array $keys Array of keys under which the cache to deleted.
|
||||
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
||||
* @return array Array of return values.
|
||||
*/
|
||||
function wp_cache_delete_multiple( array $keys, $group = '' ) {
|
||||
$values = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
$values[ $key ] = wp_cache_delete( $key, $group );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
if ( ! function_exists( 'wp_cache_add_multiple' ) ) :
|
||||
/**
|
||||
* Adds multiple values to the cache in one call, if the cache keys don't already exist.
|
||||
@@ -120,3 +65,57 @@ if ( ! function_exists( 'wp_cache_set_multiple' ) ) :
|
||||
return $values;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'wp_cache_get_multiple' ) ) :
|
||||
/**
|
||||
* Retrieves multiple values from the cache in one call.
|
||||
*
|
||||
* Compat function to mimic wp_cache_get_multiple().
|
||||
*
|
||||
* @ignore
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @see wp_cache_get_multiple()
|
||||
*
|
||||
* @param array $keys Array of keys under which the cache contents are stored.
|
||||
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
||||
* @param bool $force Optional. Whether to force an update of the local cache
|
||||
* from the persistent cache. Default false.
|
||||
* @return array Array of values organized into groups.
|
||||
*/
|
||||
function wp_cache_get_multiple( $keys, $group = '', $force = false ) {
|
||||
$values = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
$values[ $key ] = wp_cache_get( $key, $group, $force );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'wp_cache_delete_multiple' ) ) :
|
||||
/**
|
||||
* Deletes multiple values from the cache in one call.
|
||||
*
|
||||
* Compat function to mimic wp_cache_delete_multiple().
|
||||
*
|
||||
* @ignore
|
||||
* @since 6.0.0
|
||||
*
|
||||
* @see wp_cache_delete_multiple()
|
||||
*
|
||||
* @param array $keys Array of keys under which the cache to deleted.
|
||||
* @param string $group Optional. Where the cache contents are grouped. Default empty.
|
||||
* @return array Array of return values.
|
||||
*/
|
||||
function wp_cache_delete_multiple( array $keys, $group = '' ) {
|
||||
$values = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
$values[ $key ] = wp_cache_delete( $key, $group );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user