WP_AI_Client_Cache::getMultiple
Obtains multiple cache items by their unique keys.
Method of the class: WP_AI_Client_Cache{}
No Hooks.
Returns
Array
Usage
$WP_AI_Client_Cache = new WP_AI_Client_Cache(); $WP_AI_Client_Cache->getMultiple( $keys, $default_value ): array;
- $keys(iterable
) (required) - A list of keys that can be obtained in a single operation.
- $default_value(mixed)
- Default value to return for keys that do not exist.
Default:null
Changelog
| Since 7.0.0 | Introduced. |
WP_AI_Client_Cache::getMultiple() WP AI Client Cache::getMultiple code WP 7.0
public function getMultiple( $keys, $default_value = null ): array {
/**
* Keys array.
*
* @var array<string> $keys_array
*/
$keys_array = $this->iterable_to_array( $keys );
$values = wp_cache_get_multiple( $keys_array, self::CACHE_GROUP );
$result = array();
foreach ( $keys_array as $key ) {
if ( false === $values[ $key ] ) {
// Could be a stored false or a cache miss — disambiguate via get().
$result[ $key ] = $this->get( $key, $default_value );
} else {
$result[ $key ] = $values[ $key ];
}
}
return $result;
}