wppaste
WordPress

WP_AI_Client_Cache::setMultiple( $values, null|int|DateInterval $ttl = null ): bool

Since
7.0.0
Source
wp-includes/ai-client/adapters/class-wp-ai-client-cache.php:160
Persists a set of key => value pairs in the cache, with an optional TTL.

Compatibility

WordPress
since 7.0.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 2 of the 5 tracked releases, added in 7.0.0, and compiles on PHP 7.4 through 8.6-dev.

Parameters

$values
$ttlnull|int|DateIntervaloptional
The TTL value of this item.Default: null

Return value

bool
True on success and false on failure.

Performance profile

How much work a call to WP_AI_Client_Cache::setMultiple() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Only touches the object cache, via wp_cache_set_multiple().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
22

Executed per call on PHP 8.5. The body compiles to 22.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • cacheobject cachewp_cache_set_multiple()called directly

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_AI_Client_Cache::setMultiple() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always22->iterable_to_array(), ->ttl_to_seconds(), ->get_cache_group(), wp_cache_set_multiple()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev22220
8.522220
8.4222203 fewer instructions than PHP 8.3
8.325250
8.225250
8.125250
7.425250

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 4

Source code

	public function setMultiple( $values, $ttl = null ): bool {		$values_array = $this->iterable_to_array( $values );		$expire       = $this->ttl_to_seconds( $ttl );		$results      = wp_cache_set_multiple( $values_array, $this->get_cache_group(), $expire ); 		// Return true only if all operations succeeded.		return ! in_array( false, $results, true );	}

Changelog

Introduced in 7.0.0. Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 7.1.0

Signature, return type and hooks compared across 2 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/ai-client/adapters/class-wp-ai-client-cache.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.