Changeset 1022567
- Timestamp:
- 11/09/2014 07:31:37 PM (10 years ago)
- Location:
- hyper-cache-extended/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
hyper-cache-extended/trunk/cache.php
r629177 r1022567 25 25 return false; 26 26 } 27 28 if(!$hyper_cache['load']){$hyper_cache['load'] = 5;} 29 30 31 $loadavg = explode(' ',@file_get_contents('/proc/loadavg')); 32 $server_load = (float)$loadavg[0]; 33 34 27 35 28 36 $hyper_uri = $_SERVER['REQUEST_URI']; … … 85 93 // Do not use or cache pages when a wordpress user is logged on 86 94 foreach ($_COOKIE as $n => $v) { 87 // If it's required to bypass the cache when the visitor is a commenter , stop.88 if ($hyper_cache['comment'] && substr($n, 0, 15) == 'comment_author_' )95 // If it's required to bypass the cache when the visitor is a commenter AND server load is bellow critical, stop. 96 if ($hyper_cache['comment'] && substr($n, 0, 15) == 'comment_author_' && $server_load < $hyper_cache['load']) 89 97 return false; 90 98 … … 116 124 return; 117 125 } 118 119 if(!$hyper_cache['load']) $hyper_cache['load'] = 5;120 121 $loadavg = explode(' ',@file_get_contents('/proc/loadavg'));122 $server_load = (float)$loadavg[0];123 126 124 127 $hc_file_time = @ filemtime($hc_file); -
hyper-cache-extended/trunk/options.php
r923973 r1022567 190 190 </td> 191 191 </tr> 192 192 <?php 193 $numCpus = false; 194 if (is_file('/proc/cpuinfo') && is_readable('/proc/cpuinfo')){ 195 $cpuinfo = file_get_contents('/proc/cpuinfo'); 196 preg_match_all('/^processor/m', $cpuinfo, $matches); 197 $numCpus = count($matches[0]); 198 } 199 200 ?> 193 201 194 202 <tr valign="top"> … … 197 205 <input type="text" size="5" name="options[load]" value="<?php echo htmlspecialchars($options['load']); ?>"/> 198 206 <br /> 199 <?php _e('Hyper Cache Extended will serve the cached pages until Server Load gets below this number ', 'hyper-cache');?>207 <?php _e('Hyper Cache Extended will serve the cached pages until Server Load gets below this number. '.($numCpus?'Optimal value: '.($numCpus+1):''), 'hyper-cache');?> 200 208 </td> 201 209 </tr> -
hyper-cache-extended/trunk/plugin.php
r923973 r1022567 43 43 function hyper_activate(){ 44 44 $hce_options = get_option('hyper_cache_extended'); 45 45 46 46 47 $options = array(); … … 57 58 $options['expire_type'] = 'post'; 58 59 $options['path'] = WP_CONTENT_DIR.'/cache/'; 60 61 if (is_file('/proc/cpuinfo') && is_readable('/proc/cpuinfo')){ 62 $cpuinfo = file_get_contents('/proc/cpuinfo'); 63 preg_match_all('/^processor/m', $cpuinfo, $matches); 64 $numCpus = count($matches[0]); 65 $options['load'] = $numCpus + 1; 66 } 67 59 68 60 69 $buffer = hyper_generate_config($options);
Note: See TracChangeset
for help on using the changeset viewer.