WP_Object_Cache::set

Advertisement

Summery Summery

Sets the data contents into the cache.

Syntax Syntax

WP_Object_Cache::set( int|string $key, mixed $data, string $group = 'default', int $expire )

Description Description

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.

Parameters Parameters

$key

(Required) What to call the contents in the cache.

$data

(Required) The contents to store in the cache.

$group

(Optional) Where to group the cache contents. Default 'default'.

Default value: 'default'

$expire

(Optional) Not Used.

Return Return

(true) Always returns true.

Source Source

File: wp-includes/class-wp-object-cache.php

	/**
	 * 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.
	 *
	 * @since 2.0.0
	 *
	 * @param int|string $key    What to call the contents in the cache.

Advertisement

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Advertisement

Leave a Reply