Changeset 672 for plugins/staticcache/trunk/staticcache.plugin.php
- Timestamp:
- 07/12/08 04:43:43 (4 months ago)
- Files:
-
- 1 modified
-
plugins/staticcache/trunk/staticcache.plugin.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/staticcache/trunk/staticcache.plugin.php
r594 r672 35 35 36 36 //don't cache pages matching ignore list keywords 37 if ( preg_match( "@.*($ignore_list).*@i", $request ) || !Options::get( 'staticcache__ignore_list' )) {37 if ( preg_match( "@.*($ignore_list).*@i", $request ) ) { 38 38 return; 39 39 } … … 42 42 $query_id = self::get_query_id(); 43 43 44 if ( Cache::has( "staticcache:$request_id") ) {45 $cache = Cache::get( "staticcache:$request_id");44 if ( Cache::has( array("staticcache", $request_id) ) ) { 45 $cache = Cache::get( array("staticcache", $request_id) ); 46 46 if ( isset( $cache[$query_id] ) ) { 47 47 global $profile_start; … … 49 49 $time = microtime(true) - $profile_start; 50 50 echo "<!-- Served by StaticCache in $time seconds -->"; 51 Options::set( 52 'staticcache__average_time', 53 ( Options::get('staticcache__average_time') + $time ) / 2 54 ); 51 55 exit; 52 56 } … … 55 59 } 56 60 57 public function cache_invalidate( $url ) 61 public function filter_dash_modules( $modules ) 62 { 63 $this->add_template( 'static_cache_stats', dirname( __FILE__ ) . '/dash_module_staticcache.php' ); 64 $modules[] = 'Static Cache'; 65 return $modules; 66 } 67 68 public function filter_dash_module_static_cache( $module, $id, $theme ) 69 { 70 $theme->static_cache_average = sprintf( '%0.4f', Options::get('staticcache__average_time') ); 71 $theme->static_cache_pages = count( Cache::get_group('staticcache') ); 72 $module['content'] = $theme->fetch( 'static_cache_stats' ); 73 return $module; 74 } 75 76 public function cache_invalidate( $urls ) 58 77 { 59 78 foreach ( Users::get_all() as $user ) { 60 $request_id = self::get_request_id( $user->id, $url ); 61 if ( Cache::has( "staticcache:$request_id" ) ) { 62 Cache::expire( "staticcache:$request_id" ); 79 foreach( $urls as $url ) { 80 $request_id = self::get_request_id( $user->id, $url ); 81 if ( Cache::has( array("staticcache", $request_id) ) ) { 82 Cache::expire( array("staticcache", $request_id) ); 83 } 63 84 } 64 85 } … … 75 96 $post->comment_feed_link, 76 97 $post->permalink, 77 URL::get( 'atom_feed', 'index=1' ) 98 URL::get( 'atom_feed', 'index=1' ), 99 Site::get_url( 'habari' ) 78 100 ); 79 101 $this->cache_invalidate( $urls ); … … 90 112 $comment->post->comment_feed_link, 91 113 $comment->post->permalink, 92 URL::get( 'atom_feed', 'index=1' ) 114 URL::get( 'atom_feed', 'index=1' ), 115 Site::get_url( 'habari' ) 93 116 ); 94 117 $this->cache_invalidate( $urls ); … … 156 179 $query_id = StaticCache::get_query_id(); 157 180 158 if ( Cache::has( "staticcache:$request_id") ) {159 $cache = Cache::get( "staticcache:$request_id");181 if ( Cache::has( array("staticcache", $request_id) ) ) { 182 $cache = Cache::get( array("staticcache", $request_id) ); 160 183 $cache[$query_id] = $buffer; 161 184 } 162 185 else { 163 $cache = array( $ request_id => array( $query_id => $buffer ));186 $cache = array( $query_id => $buffer ); 164 187 } 165 Cache::set( "staticcache:$request_id", $cache );188 Cache::set( array("staticcache", $request_id), $cache ); 166 189 167 190 return false; 168 191 } 169 192 170 171 193 ?>
