Add expiration for transients

git-svn-id: https://develop.svn.wordpress.org/trunk@10603 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2009-02-20 02:23:11 +00:00
parent f90ad3f54d
commit 999851f2cb
2 changed files with 31 additions and 23 deletions
+5 -18
View File
@@ -712,10 +712,8 @@ class RSSCache {
function set ($url, $rss) {
global $wpdb;
$cache_option = 'rss_' . $this->file_name( $url );
$cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
set_transient($cache_option, $rss);
set_transient($cache_timestamp, time() );
set_transient($cache_option, $rss, $this->MAX_AGE);
return $cache_option;
}
@@ -749,23 +747,12 @@ class RSSCache {
\*=======================================================================*/
function check_cache ( $url ) {
$this->ERROR = "";
$cache_option = $this->file_name( $url );
$cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
$cache_option = 'rss_' . $this->file_name( $url );
if ( $mtime = get_transient($cache_timestamp) ) {
// find how long ago the file was added to the cache
// and whether that is longer then MAX_AGE
$age = time() - $mtime;
if ( $this->MAX_AGE > $age ) {
// object exists and is current
if ( get_transient($cache_option) ) {
// object exists and is current
return 'HIT';
}
else {
// object exists but is old
return 'STALE';
}
}
else {
} else {
// object does not exist
return 'MISS';
}