Más contenido relacionado La actualidad más candente (20) Similar a WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress (20) Más de WordCamp Kyiv (15) WordPress Kitchen 2014 - Александр Стриха: Кеширование в WordPress 18. function get_free_products_count()
{
if ( false === ( $count = wp_cache_get( 'free-products' ) ) ) {
$count = big query
wp_cache_set( 'free-products', $count );
}
return $count;
}
get_free_products_count(); // SQL
get_free_products_count(); // Cache
get_free_products_count(); // Cache
21. if ( false === ( $value = get_transient( 'key' ) ) ) {
$value = wp_remote_get( $url );
set_transient( 'key', $value, DAY_IN_SECONDS );
}
22. if ( false === ( $value = get_transient( 'key' ) ) ) {
$value = BIG QUERY
set_transient( 'key', $value, DAY_IN_SECONDS );
}
24. if ( false === ( $value = get_transient( 'key' ) ) ) {
ob_start();
get_sidebar();
$value = ob_get_clean();
set_transient( 'key', $value, DAY_IN_SECONDS );
}
28. function wp_cache_postload( ) {
$key = 'page_cache' . $_SERVER[ 'REQUEST_URI' ];
if ( $html = get_transient( $key ) ) {
echo $html;
exit;
}
oobb__start( function( $html ) use ( $key ) {
set_transient( $key, $html, HOUR_IN_SECONDS );
return $html;
});
}