WP_REST_URL_Details_Controller::set_cache
Utility function to cache a given data set at a given cache key.
Метод класса: WP_REST_URL_Details_Controller{}
Хуки из метода
Возвращает
bool. True when transient set. False if not set.
Использование
// private - только в коде основоного (родительского) класса $result = $this->set_cache( $key, $data );
- $key(строка) (обязательный)
- The cache key under which to store the value.
- $data(строка)
- The data to be stored at the given cache key.
По умолчанию:''
Список изменений
| С версии 5.9.0 | Введена. |
Код WP_REST_URL_Details_Controller::set_cache() WP REST URL Details Controller::set cache WP 7.1
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 );
}