wp/wp-includes/cache-compat.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
--- a/wp/wp-includes/cache-compat.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/cache-compat.php	Fri Sep 05 18:40:08 2025 +0200
@@ -138,6 +138,64 @@
 	 * @return bool True on success, false on failure.
 	 */
 	function wp_cache_flush_runtime() {
-		return wp_using_ext_object_cache() ? false : wp_cache_flush();
+		if ( ! wp_cache_supports( 'flush_runtime' ) ) {
+			_doing_it_wrong(
+				__FUNCTION__,
+				__( 'Your object cache implementation does not support flushing the in-memory runtime cache.' ),
+				'6.1.0'
+			);
+
+			return false;
+		}
+
+		return wp_cache_flush();
 	}
 endif;
+
+if ( ! function_exists( 'wp_cache_flush_group' ) ) :
+	/**
+	 * Removes all cache items in a group, if the object cache implementation supports it.
+	 *
+	 * Before calling this function, always check for group flushing support using the
+	 * `wp_cache_supports( 'flush_group' )` function.
+	 *
+	 * @since 6.1.0
+	 *
+	 * @see WP_Object_Cache::flush_group()
+	 * @global WP_Object_Cache $wp_object_cache Object cache global instance.
+	 *
+	 * @param string $group Name of group to remove from cache.
+	 * @return bool True if group was flushed, false otherwise.
+	 */
+	function wp_cache_flush_group( $group ) {
+		global $wp_object_cache;
+
+		if ( ! wp_cache_supports( 'flush_group' ) ) {
+			_doing_it_wrong(
+				__FUNCTION__,
+				__( 'Your object cache implementation does not support flushing individual groups.' ),
+				'6.1.0'
+			);
+
+			return false;
+		}
+
+		return $wp_object_cache->flush_group( $group );
+	}
+endif;
+
+if ( ! function_exists( 'wp_cache_supports' ) ) :
+	/**
+	 * Determines whether the object cache implementation supports a particular feature.
+	 *
+	 * @since 6.1.0
+	 *
+	 * @param string $feature Name of the feature to check for. Possible values include:
+	 *                        'add_multiple', 'set_multiple', 'get_multiple', 'delete_multiple',
+	 *                        'flush_runtime', 'flush_group'.
+	 * @return bool True if the feature is supported, false otherwise.
+	 */
+	function wp_cache_supports( $feature ) {
+		return false;
+	}
+endif;