WordPress at a glance
function is not described

WP_Object_Cache::set() WP 2.0.0

Sets the data contents into the cache.

The cache contents are grouped by the $group parameter followed by the $key. This allows for duplicate ids in unique groups. Therefore, naming of the group should be used with care and should follow normal function naming guidelines outside of core WordPress usage.

The $expire parameter is not used, because the cache will automatically expire for each time a page is accessed and PHP finishes. The method is more for cache plugins which use files.

This is a method of the class: WP_Object_Cache

No Hooks.

Return

true. Always returns true.

Usage

$WP_Object_Cache = new WP_Object_Cache();
$var = $WP_Object_Cache->set( $key, $data, $group, $expire );
$key(int/string) (required)
What to call the contents in the cache.
$data(mixed) (required)
The contents to store in the cache.
$group(string)
Where to group the cache contents.
Default: 'default'
$expire(int)
Not Used.
Default: 0

Changelog

Since 2.0.0 Introduced.

Code of WP Object Cache::set: wp-includes/cache.php WP 5.2.3

<?php
public function set( $key, $data, $group = 'default', $expire = 0 ) {
	if ( empty( $group ) ) {
		$group = 'default';
	}

	if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
		$key = $this->blog_prefix . $key;
	}

	if ( is_object( $data ) ) {
		$data = clone $data;
	}

	$this->cache[ $group ][ $key ] = $data;
	return true;
}