Caching for get_pages

git-svn-id: http://svn.automattic.com/wordpress/trunk@4521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2006-11-23 17:21:08 +00:00
parent b7d514be34
commit 226a7a48eb
1 changed files with 17 additions and 4 deletions

View File

@ -1038,10 +1038,15 @@ function &get_pages($args = '') {
$r = array_merge($defaults, $r);
extract($r);
$key = md5( serialize( $r ) );
if ( $cache = wp_cache_get( 'get_pages', 'page' ) )
if ( isset( $cache[ $key ] ) )
return apply_filters('get_pages', $cache[ $key ], $r );
$inclusions = '';
if ( !empty($include) ) {
$child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
$exclude = '';
$child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
$exclude = '';
$meta_key = '';
$meta_value = '';
$incpages = preg_split('/[\s,]+/',$include);
@ -1054,8 +1059,8 @@ function &get_pages($args = '') {
}
}
}
if (!empty($inclusions))
$inclusions .= ')';
if (!empty($inclusions))
$inclusions .= ')';
$exclusions = '';
if ( !empty($exclude) ) {
@ -1117,9 +1122,17 @@ function &get_pages($args = '') {
if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of, $pages);
$cache[ $key ] = $pages;
wp_cache_set( 'get_pages', $cache, 'page' );
return $pages;
}
function delete_get_pages_cache() {
wp_cache_delete( 'get_pages', 'page' );
}
add_action( 'save_post', 'delete_get_pages_cache' );
function generate_page_uri_index() {
global $wpdb;