Title: WP_AI_Client_Cache::clear
Published: May 20, 2026

---

# WP_AI_Client_Cache::clear(): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#wp--skip-link--target)

Wipes clean the entire cache’s keys.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#description)󠁿

This method only clears the cache group used by this adapter. If the underlying 
cache implementation does not support group flushing, this method returns false.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#return)󠁿

 bool True on success and false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#source)󠁿

    ```php
    public function clear(): bool {
    	if ( ! function_exists( 'wp_cache_supports' ) || ! wp_cache_supports( 'flush_group' ) ) {
    		return false;
    	}

    	return wp_cache_flush_group( self::CACHE_GROUP );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php#L90)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php#L90-L96)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_cache_supports()](https://developer.wordpress.org/reference/functions/wp_cache_supports/)`wp-includes/cache.php` |

Determines whether the object cache implementation supports a particular feature.

  | 
| [wp_cache_flush_group()](https://developer.wordpress.org/reference/functions/wp_cache_flush_group/)`wp-includes/cache.php` |

Removes all cache items in a group, if the object cache implementation supports it.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/clear/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_ai_client_cache%2Fclear%2F)
before being able to contribute a note or feedback.