Cache API: Make the placement of `wp_cache_flush_group()` more consistent.

Includes:
* Placing `WP_Object_Cache::flush_group()` next to `::flush()`.
* Placing `wp_cache_supports_group_flush()` next to `wp_cache_flush_group()`.
* Placing the `wp_cache_flush_group()` unit test next to the `::flush()` method test.
* Removing test name from assertion messages, as it is already mentioned directly above in case of failure.
* Adjusting function descriptions per the documentation standards.

Follow-up to [52706], [53763].

See #55647, #4476.
Built from https://develop.svn.wordpress.org/trunk@53767


git-svn-id: http://core.svn.wordpress.org/trunk@53326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-07-23 14:58:12 +00:00
parent 85e2d1df55
commit d61b862297
4 changed files with 35 additions and 33 deletions

View File

@ -145,8 +145,9 @@ endif;
if ( ! function_exists( 'wp_cache_flush_group' ) ) : if ( ! function_exists( 'wp_cache_flush_group' ) ) :
/** /**
* Removes all cache items in a group, if the object cache implementation supports it. * Removes all cache items in a group, if the object cache implementation supports it.
* Before calling this method, always check for group flushing support using the *
* `wp_cache_supports_group_flush()` method. * Before calling this function, always check for group flushing support using the
* `wp_cache_supports_group_flush()` function.
* *
* @since 6.1.0 * @since 6.1.0
* *
@ -175,7 +176,7 @@ endif;
if ( ! function_exists( 'wp_cache_supports_group_flush' ) ) : if ( ! function_exists( 'wp_cache_supports_group_flush' ) ) :
/** /**
* Whether the object cache implementation supports flushing individual cache groups. * Determines whether the object cache implementation supports flushing individual cache groups.
* *
* @since 6.1.0 * @since 6.1.0
* *

View File

@ -22,19 +22,6 @@ function wp_cache_init() {
$GLOBALS['wp_object_cache'] = new WP_Object_Cache(); $GLOBALS['wp_object_cache'] = new WP_Object_Cache();
} }
/**
* Whether the object cache implementation supports flushing individual cache groups.
*
* @since 6.1.0
*
* @see WP_Object_Cache::flush_group()
*
* @return bool True if group flushing is supported, false otherwise.
*/
function wp_cache_supports_group_flush() {
return true;
}
/** /**
* Adds data to the cache, if the cache key doesn't already exist. * Adds data to the cache, if the cache key doesn't already exist.
* *
@ -296,8 +283,9 @@ function wp_cache_flush_runtime() {
/** /**
* Removes all cache items in a group, if the object cache implementation supports it. * Removes all cache items in a group, if the object cache implementation supports it.
* Before calling this method, always check for group flushing support using the *
* `wp_cache_supports_group_flush()` method. * Before calling this function, always check for group flushing support using the
* `wp_cache_supports_group_flush()` function.
* *
* @since 6.1.0 * @since 6.1.0
* *
@ -313,6 +301,19 @@ function wp_cache_flush_group( $group ) {
return $wp_object_cache->flush_group( $group ); return $wp_object_cache->flush_group( $group );
} }
/**
* Determines whether the object cache implementation supports flushing individual cache groups.
*
* @since 6.1.0
*
* @see WP_Object_Cache::flush_group()
*
* @return bool True if group flushing is supported, false otherwise.
*/
function wp_cache_supports_group_flush() {
return true;
}
/** /**
* Closes the cache. * Closes the cache.
* *

View File

@ -290,20 +290,6 @@ class WP_Object_Cache {
return $values; return $values;
} }
/**
* Removes all cache items in a group.
*
* @since 6.1.0
*
* @param string $group Name of group to remove from cache.
* @return true Always returns true.
*/
public function flush_group( $group ) {
unset( $this->cache[ $group ] );
return true;
}
/** /**
* Retrieves the cache contents, if it exists. * Retrieves the cache contents, if it exists.
* *
@ -509,6 +495,20 @@ class WP_Object_Cache {
return true; return true;
} }
/**
* Removes all cache items in a group.
*
* @since 6.1.0
*
* @param string $group Name of group to remove from cache.
* @return true Always returns true.
*/
public function flush_group( $group ) {
unset( $this->cache[ $group ] );
return true;
}
/** /**
* Sets the list of global cache groups. * Sets the list of global cache groups.
* *

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.1-alpha-53766'; $wp_version = '6.1-alpha-53767';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.