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

---

# WP_AI_Client_Cache::get( string $key, mixed $default_value = null ): mixed

## In this article

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

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

Fetches a value from the cache.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/get/?output_format=md#parameters)󠁿

 `$key`stringrequired

The unique key of this item in the cache.

`$default_value`mixedoptional

Default value to return if the key does not exist.

Default:`null`

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

 mixed The value of the item from the cache, or $default_value in case of cache 
miss.

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

    ```php
    public function get( $key, $default_value = null ) {
    	$found = false;
    	$value = wp_cache_get( $key, self::CACHE_GROUP, false, $found );

    	if ( ! $found ) {
    		return $default_value;
    	}

    	return $value;
    }
    ```

[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#L41)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php#L41-L50)

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

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

Retrieves the cache contents from the cache by key and group.

  |

| Used by | Description | 
| [WP_AI_Client_Cache::getMultiple()](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/getmultiple/)`wp-includes/ai-client/adapters/class-wp-ai-client-cache.php` |

Obtains multiple cache items by their unique keys.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_ai_client_cache/get/?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%2Fget%2F)
before being able to contribute a note or feedback.