Automattic\WooCommerce\Admin\API\Reports

Cache::set │ public static │ WC 1.0

Update cached value.

Method of the class: Cache{}

Hooks from the method

Returns

bool.

Usage

$result = Cache::set( $key, $value );
$key(string) (required)
Cache key.
$value(mixed) (required)
New value.

Cache::set() code WC 11.3.0

public static function set( $key, $value ) {
	$transient_version = self::get_version();
	$transient_value   = array(
		'version' => $transient_version,
		'value'   => $value,
	);

	/**
	 * Filters how long a reports cache value is kept, in seconds.
	 *
	 * @since 11.3.0
	 *
	 * @param int    $expiration Time until expiration in seconds. Must be greater than 0; other values use the default of one week.
	 * @param string $key        Cache key.
	 */
	$expiration = apply_filters( 'woocommerce_reports_cache_expiration', WEEK_IN_SECONDS, $key );
	$expiration = is_numeric( $expiration ) && $expiration > 0 && is_finite( (float) $expiration ) ? (int) ceil( (float) $expiration ) : WEEK_IN_SECONDS;

	$result = set_transient( $key, $transient_value, $expiration );

	return $result;
}