diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-15 17:38:20 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-15 17:38:20 +0000 |
commit | 5dbc4a0b5bbf235830a38b2cfab07c46a7a9c2eb (patch) | |
tree | 1e472390729ba6ce50ea96c8f4f1956e5fd14b0b /wp-includes/rss.php | |
parent | bc77bc1ec3c34976337a5188f5b4a24feb7fc88c (diff) | |
download | wordpress-mu-5dbc4a0b5bbf235830a38b2cfab07c46a7a9c2eb.tar.gz wordpress-mu-5dbc4a0b5bbf235830a38b2cfab07c46a7a9c2eb.tar.xz wordpress-mu-5dbc4a0b5bbf235830a38b2cfab07c46a7a9c2eb.zip |
Allow Magpie RSS class to use a global cache or sitemeta for caching feeds
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1291 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/rss.php')
-rw-r--r-- | wp-includes/rss.php | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/wp-includes/rss.php b/wp-includes/rss.php index 18e489d..f655f12 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -672,18 +672,19 @@ class RSSCache { Output: true on sucess \*=======================================================================*/ function set ($url, $rss) { - global $wpdb; + global $wpdb, $wp_object_cache; $cache_option = 'rss_' . $this->file_name( $url ); $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; - // shouldn't these be using get_option() ? - if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_option ) ) ) - add_option($cache_option, '', '', 'no'); - if ( !$wpdb->get_var( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name = %s", $cache_timestamp ) ) ) - add_option($cache_timestamp, '', '', 'no'); - - update_option($cache_option, $rss); - update_option($cache_timestamp, time() ); + if( $wp_object_cache->cache_enabled ) { + wp_cache_set( $cache_option, $rss, 'site-options' ); + wp_cache_set( $cache_timestamp, $cache_timestamp, 'site-options' ); + } else { + if( !get_site_option( $cache_option ) ) + add_site_option( $cache_option, $rss ); + if( !get_site_option( $cache_timestamp ) ) + add_site_option( $cache_timestamp, $cache_timestamp ); + } return $cache_option; } @@ -695,19 +696,23 @@ class RSSCache { Output: cached object on HIT, false on MISS \*=======================================================================*/ function get ($url) { + global $wp_object_cache; $this->ERROR = ""; $cache_option = 'rss_' . $this->file_name( $url ); - if ( ! get_option( $cache_option ) ) { - $this->debug( - "Cache doesn't contain: $url (cache option: $cache_option)" - ); - return 0; + if( $wp_object_cache->cache_enabled ) { + if( ! wp_cache_get( $cache_option, 'site-options' ) ) { + $this->debug( "Cache doesn't contain: $url (cache option: $cache_option)" ); + return 0; + } + return wp_cache_get( $cache_option, 'site-options' ); + } else { + if ( ! get_option( $cache_option ) ) { + $this->debug( "Cache doesn't contain: $url (cache option: $cache_option)" ); + return 0; + } + return get_option( $cache_option ); } - - $rss = get_option( $cache_option ); - - return $rss; } /*=======================================================================*\ @@ -718,11 +723,18 @@ class RSSCache { Output: cached object on HIT, false on MISS \*=======================================================================*/ function check_cache ( $url ) { + global $wp_object_cache; $this->ERROR = ""; $cache_option = $this->file_name( $url ); $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts'; - if ( $mtime = get_option($cache_timestamp) ) { + if( $wp_object_cache->cache_enabled ) { + $mtime = wp_cache_get( $cache_timestamp, 'site-options' ); + } else { + $mtime = get_option($cache_timestamp); + } + + if ( $mtime ) { // find how long ago the file was added to the cache // and whether that is longer then MAX_AGE $age = time() - $mtime; |