Utility function to cache a given data set at a given cache key.
Parameters
$key
stringrequired- The cache key under which to store the value.
$data
stringoptional- The data to be stored at the given cache key.
Default:
''
Source
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.
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.