diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-08-14 18:08:03 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-08-14 18:20:08 +0200 |
commit | c1cb9059ee60ae1bf1fd20afcf399b5616c8e740 (patch) | |
tree | 2fcbf4a58825ea4bb0a011cc752d442d16774c38 /system/application/models | |
parent | b82315dfebf9a77d8b5114afcab0cad27c3f40ac (diff) |
use memcache
Signed-off-by: Florian Pritz <bluewind@xssn.at>
Diffstat (limited to 'system/application/models')
-rw-r--r-- | system/application/models/file_mod.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php index 8c197546c..07c3e5555 100644 --- a/system/application/models/file_mod.php +++ b/system/application/models/file_mod.php @@ -182,8 +182,16 @@ class File_mod extends Model { } echo $this->load->view('file/html_header', $data, true); if ($mode == "rmd") { - echo '<td class="markdownrender">'."\n"; - passthru('/usr/bin/perl /usr/bin/perlbin/vendor/Markdown.pl '.escapeshellarg($file)); + $this->load->library("MemcacheLibrary"); + if (! $cached = $this->memcachelibrary->get($filedata['hash'].'_'.$mode)) { + ob_start(); + echo '<td class="markdownrender">'."\n"; + passthru('/usr/bin/perl /usr/bin/perlbin/vendor/Markdown.pl '.escapeshellarg($file)); + $cached = ob_get_contents(); + ob_end_clean(); + $this->memcachelibrary->set($filedata['hash'].'_'.$mode, $cached, 100); + } + echo $cached; } else { echo '<td class="numbers"><pre>'; // only rewrite if it's fast @@ -197,7 +205,15 @@ class File_mod extends Model { } fclose($fp); } else { - passthru('/usr/bin/pygmentize -l '.$mode.' -f html '.escapeshellarg($file)); + $this->load->library("MemcacheLibrary"); + if (! $cached = $this->memcachelibrary->get($filedata['hash'].'_'.$mode)) { + ob_start(); + passthru('/usr/bin/pygmentize -l '.$mode.' -f html '.escapeshellarg($file)); + $cached = ob_get_contents(); + ob_end_clean(); + $this->memcachelibrary->set($filedata['hash'].'_'.$mode, $cached, 100); + } + echo $cached; } echo '</pre>'; } |