On this page
WP_REST_URL_Details_Controller::set_cache( string $key, string $data = '' ): bool
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.
Utility function to cache a given data set at a given cache key.
Parameters
$keystring Required-
The cache key under which to store the value.
$datastring Optional-
The data to be stored at the given cache key.
Default:
''
Return
bool True when transient set. False if not set.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php. View all references
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 );
}
Hooks
- apply_filters( 'rest_url_details_cache_expiration',
int $ttl ) -
Filters the cache expiration.
Related
Uses
| Uses | Description |
|---|---|
| set_site_transient() wp-includes/option.php | Sets/updates the value of a site transient. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| WP_REST_URL_Details_Controller::parse_url_details() wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php | Retrieves the contents of the title tag from the HTML response. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_url_details_controller/set_cache