WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/20/2009 02:23:11 AM (11 years ago)
Author:
ryan
Message:

Add expiration for transients

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/rss.php

    r10512 r10603  
    713713        global $wpdb;
    714714        $cache_option = 'rss_' . $this->file_name( $url );
    715         $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
    716 
    717         set_transient($cache_option, $rss);
    718         set_transient($cache_timestamp, time() );
     715
     716        set_transient($cache_option, $rss, $this->MAX_AGE);
    719717
    720718        return $cache_option;
     
    750748    function check_cache ( $url ) {
    751749        $this->ERROR = "";
    752         $cache_option = $this->file_name( $url );
    753         $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
    754 
    755         if ( $mtime = get_transient($cache_timestamp) ) {
    756             // find how long ago the file was added to the cache
    757             // and whether that is longer then MAX_AGE
    758             $age = time() - $mtime;
    759             if ( $this->MAX_AGE > $age ) {
    760                 // object exists and is current
     750        $cache_option = 'rss_' . $this->file_name( $url );
     751
     752        if ( get_transient($cache_option) ) {
     753            // object exists and is current
    761754                return 'HIT';
    762             }
    763             else {
    764                 // object exists but is old
    765                 return 'STALE';
    766             }
    767         }
    768         else {
     755        } else {
    769756            // object does not exist
    770757            return 'MISS';
Note: See TracChangeset for help on using the changeset viewer.