twitter_stream_cache

The Twitter Stream twitter stream cache function.

Description

twitter_stream_cache( $modtime, $cache_path, $cache_time ); 

Parameters (3)

0. $modtime
The modtime.
1. $cache_path
The cache path.
2. $cache_time
The cache time.

Usage

  1. if ( !function_exists( 'twitter_stream_cache' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'twitter-stream/twitter-stream.php'; 
  3.  
  4. // The modtime. 
  5. $modtime = null; 
  6.  
  7. // The cache path. 
  8. $cache_path = null; 
  9.  
  10. // The cache time. 
  11. $cache_time = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = twitter_stream_cache($modtime, $cache_path, $cache_time); 
  15.  

Defined (1)

The function is defined in the following location(s).

/twitter-stream.php  
  1. function twitter_stream_cache($modtime, $cache_path, $cache_time) { 
  2.  
  3. $thirtyago = time() - $cache_time; //the timestamp thirty minutes ago 
  4.  
  5. if($modtime < $thirtyago) { 
  6. //our cache is older than 30 minutes return FALSE so the script will run the cache updater. 
  7. return FALSE; 
  8.  
  9. //We have already checked that the file exists. So we can assume it exsits here. 
  10. $data = file_get_contents($cache_path); 
  11.  
  12. $data = json_decode($data); 
  13.  
  14. if($data !== FALSE) { 
  15. return $data; //return our data if there wasn't a problem 
  16.