Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_REST_URL_Details_Controller::set_cache() WordPress Method

The WP_REST_URL_Details_Controller::set_cache() method is used to set the cache for a given URL.

WP_REST_URL_Details_Controller::set_cache( string $key, string $data = '' ) #

Utility function to cache a given data set at a given cache key.


Parameters

$key

(string)(Required)The cache key under which to store the value.

$data

(string)(Optional)The data to be stored at the given cache key.

Default value: ''


Top ↑

Return

(bool) True when transient set. False if not set.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php

	private function set_cache( $key, $data = '' ) {
		$ttl = HOUR_IN_SECONDS;

		/**
		 * Filters the cache expiration.
		 *
		 * Can be used to adjust the time until expiration in seconds for the cache
		 * of the data retrieved for the given URL.
		 *
		 * @since 5.9.0
		 *
		 * @param int $ttl The time until cache expiration in seconds.
		 */
		$cache_expiration = apply_filters( 'rest_url_details_cache_expiration', $ttl );

		return set_site_transient( $key, $data, $cache_expiration );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.