From c1cb9059ee60ae1bf1fd20afcf399b5616c8e740 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 14 Aug 2010 18:08:03 +0200 Subject: use memcache Signed-off-by: Florian Pritz --- system/application/models/file_mod.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'system/application/models') 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 ''."\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 ''."\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 '
';
             // 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 '
'; } -- cgit v1.2.3-24-g4f1b