• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision51239db40c60ac247bca93349bb918146a83494f (tree)
Time2018-03-14 22:01:26
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2401 bugtrack_list: Improve cache management

Use converted HTML text when cache/recent.dat is unchanged.

Change Summary

Incremental Difference

--- a/plugin/bugtrack.inc.php
+++ b/plugin/bugtrack.inc.php
@@ -288,6 +288,7 @@ function plugin_bugtrack_get_page_list($page, $needs_filetime) {
288288 function plugin_bugtrack_list_convert()
289289 {
290290 global $vars, $_plugin_bugtrack, $_title_cannotread;
291+ global $whatsdeleted;
291292 $cache_format_version = 1;
292293 $cache_expire_time = 60 * 60 * 24;
293294 $cache_refresh_time_prev;
@@ -305,6 +306,22 @@ function plugin_bugtrack_list_convert()
305306 $body = str_replace('$1', htmlsc($page), $_title_cannotread);
306307 return $body;
307308 }
309+ if ($cache_enabled) {
310+ $cache_filepath = CACHE_DIR . encode($page) . '.bugtrack';
311+ $json_cached = pkwk_file_get_contents($cache_filepath);
312+ $wrapdata = json_decode($json_cached);
313+ if (is_object($wrapdata) && $wrapdata) {
314+ $recent_deleted_filetime = get_filetime($whatsdeleted);
315+ $recent_dat_filemtime = filemtime(CACHE_DIR . PKWK_MAXSHOW_CACHE);
316+ if ($recent_deleted_filetime === $wrapdata->recent_deleted_filetime &&
317+ $recent_dat_filemtime === $wrapdata->recent_dat_filemtime &&
318+ $recent_dat_filemtime !== false &&
319+ $recent_deleted_filetime !== 0) {
320+ return $wrapdata->html;
321+ }
322+ }
323+ }
324+ $cache_data = null;
308325 $data = array();
309326 $page_list = plugin_bugtrack_get_page_list($page, true);
310327 usort($page_list, '_plugin_bugtrack_list_paganame_compare');
@@ -400,9 +417,7 @@ EOD;
400417 } else {
401418 $refreshed_at = time();
402419 }
403- $json = array('refreshed_at'=>$refreshed_at, 'pages'=>$data, 'version'=>$cache_format_version);
404- $cache_body = json_encode($json, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
405- file_put_contents($cache_filepath, $cache_body, LOCK_EX);
420+ $cache_data = array('refreshed_at'=>$refreshed_at, 'pages'=>$data, 'version'=>$cache_format_version);
406421 }
407422 }
408423 $table = array();
@@ -419,9 +434,17 @@ EOD;
419434 ksort($table[$i], SORT_NUMERIC);
420435 $table_html .= join('', $table[$i]);
421436 }
422- return '<table border="1" width="100%">' . "\n" .
437+ $result_html = '<table border="1" width="100%">' . "\n" .
423438 $table_html . "\n" .
424439 '</table>';
440+ if ($cache_enabled) {
441+ $cache_data['recent_deleted_filetime'] = get_filetime($whatsdeleted);
442+ $cache_data['recent_dat_filemtime'] = filemtime(CACHE_DIR . PKWK_MAXSHOW_CACHE);
443+ $cache_data['html'] = $result_html;
444+ $cache_body = json_encode($cache_data, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
445+ file_put_contents($cache_filepath, $cache_body, LOCK_EX);
446+ }
447+ return $result_html;
425448 }
426449
427450 // Get one set of data from a page (or a page moved to $page)