WP_Object_Cache::add_multiple
Adds multiple values to the cache in one call.
Method of the class: WP_Object_Cache{}
No Hooks.
Returns
true|false[]. Array of return values, grouped by key. Each value is either true on success, or false if cache key and group already exist.
Usage
$WP_Object_Cache = new WP_Object_Cache(); $WP_Object_Cache->add_multiple( $data, $group, $expire );
- $data(array) (required)
- Array of keys and values to be added.
- $group(string)
- Where the cache contents are grouped.
Default:'' - $expire(int)
- When to expire the cache contents, in seconds.
Default:0 (no expiration)
Changelog
| Since 6.0.0 | Introduced. |
WP_Object_Cache::add_multiple() WP Object Cache::add multiple code WP 6.9.1
public function add_multiple( array $data, $group = '', $expire = 0 ) {
$values = array();
foreach ( $data as $key => $value ) {
$values[ $key ] = $this->add( $key, $value, $group, $expire );
}
return $values;
}