The function wp_cache_flush()
should help you but is not the same one.
The function runs on the global $wp_object_cache
and set a new empty array, different to the WP CLI deprecated function wp_clear_object_cache
for different keys of the global var.
function wp_clear_object_cache() {
global $wpdb, $wp_object_cache;
$wpdb->queries = [];
if ( ! is_object( $wp_object_cache ) ) {
return;
}
// The following are Memcached (Redux) plugin specific (see https://core.trac.wordpress.org/ticket/31463).
if ( isset( $wp_object_cache->group_ops ) ) {
$wp_object_cache->group_ops = [];
}
if ( isset( $wp_object_cache->stats ) ) {
$wp_object_cache->stats = [];
}
if ( isset( $wp_object_cache->memcache_debug ) ) {
$wp_object_cache->memcache_debug = [];
}
// Used by `WP_Object_Cache` also.
if ( isset( $wp_object_cache->cache ) ) {
$wp_object_cache->cache = [];
}
}
Note: The deprecated flag should be wrong, and the maintenance team will change them in a future version. That is information after a small talk with the team.