WP_REST_URL_Details_Controller::set_cache()privateWP 5.9.0

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

Method of the class: WP_REST_URL_Details_Controller{}

Hooks from the method


true|false. True when transient set. False if not set.


// private - for code of main (parent) class only
$result = $this->set_cache( $key, $data );
$key(string) (required)
The cache key under which to store the value.
The data to be stored at the given cache key.
Default: ''


Since 5.9.0 Introduced.

WP_REST_URL_Details_Controller::set_cache() code WP 6.3

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

	 * 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 );