W3TCCdn_CacheFlush

Class Cdn_CacheFlush.

Defined (1)

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

/Cdn_CacheFlush.php  
  1. /* class Cdn_CacheFlush 
  2. */ 
  3. class Cdn_CacheFlush { 
  4. /** 
  5. * Advanced cache config 
  6. */ 
  7. var $_config = null; 
  8.  
  9.  
  10. /** 
  11. * Array of urls to flush 
  12. * @var array 
  13. */ 
  14. private $flush_operation_requested = false; 
  15.  
  16. /** 
  17. * PHP5 Constructor 
  18. */ 
  19. function __construct() { 
  20. $this->_config = Dispatcher::config(); 
  21.  
  22. /** 
  23. * Purges everything from CDNs that supports it 
  24. */ 
  25. function purge_all() { 
  26. $this->flush_operation_requested = true; 
  27. return true; 
  28.  
  29. /** 
  30. * Purge a single url 
  31. * @param unknown $url 
  32. */ 
  33. function purge_url( $url ) { 
  34. $common = Dispatcher::component( 'Cdn_Core' ); 
  35. $results = array(); 
  36. $files = array(); 
  37. $parsed = parse_url( $url ); 
  38. $local_site_path = isset( $parsed['path'] )? ltrim( $parsed['path'], '/' ) : ''; 
  39. $remote_path = $common->uri_to_cdn_uri( $local_site_path ); 
  40. $files[] = $common->build_file_descriptor( $local_site_path, $remote_path ); 
  41. $this->_flushed_urls[] = $url; 
  42. $common->purge( $files, false, $results ); 
  43.  
  44. /** 
  45. * Clears global and repeated urls 
  46. */ 
  47. function purge_post_cleanup() { 
  48. if ( $this->flush_operation_requested ) { 
  49. $common = Dispatcher::component( 'Cdn_Core' ); 
  50. $results = array(); 
  51. $common->purge_all( $results ); 
  52.  
  53. $count = 999; 
  54.  
  55. $this->flush_operation_requested = false; 
  56.  
  57. return $count;