wppaste
WordPress

RSSCache

Source
wp-includes/rss.php:715

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 3

$BASE_CACHEpublic
$MAX_AGEpublic
$ERRORpublic

Methods · 10

Source code

class RSSCache {	var $BASE_CACHE;	// where the cache files are stored	var $MAX_AGE	= 43200;  		// when are files stale, default twelve hours	var $ERROR 		= '';			// accumulate error messages 	/**	 * PHP5 constructor.	 */	function __construct( $base = '', $age = '' ) {		$this->BASE_CACHE = WP_CONTENT_DIR . '/cache';		if ( $base ) {			$this->BASE_CACHE = $base;		}		if ( $age ) {			$this->MAX_AGE = $age;		} 	} 	/**	 * PHP4 constructor.	 */	public function RSSCache( $base = '', $age = '' ) {		self::__construct( $base, $age );	} /*=======================================================================*\	Function:	set	Purpose:	add an item to the cache, keyed on url	Input:		url from which the rss file was fetched	Output:		true on success\*=======================================================================*/	function set ($url, $rss) {		$cache_option = 'rss_' . $this->file_name( $url ); 		set_transient($cache_option, $rss, $this->MAX_AGE); 		return $cache_option;	} /*=======================================================================*\	Function:	get	Purpose:	fetch an item from the cache	Input:		url from which the rss file was fetched	Output:		cached object on HIT, false on MISS\*=======================================================================*/	function get ($url) {		$this->ERROR = "";		$cache_option = 'rss_' . $this->file_name( $url ); 		if ( ! $rss = get_transient( $cache_option ) ) {			$this->debug(				"Cache does not contain: $url (cache option: $cache_option)"			);			return 0;		} 		return $rss;	} /*=======================================================================*\	Function:	check_cache	Purpose:	check a url for membership in the cache				and whether the object is older then MAX_AGE (ie. STALE)	Input:		url from which the rss file was fetched	Output:		cached object on HIT, false on MISS\*=======================================================================*/	function check_cache ( $url ) {		$this->ERROR = "";		$cache_option = 'rss_' . $this->file_name( $url ); 		if ( get_transient($cache_option) ) {			// object exists and is current				return 'HIT';		} else {			// object does not exist			return 'MISS';		}	}

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/rss.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.