[icinga-checkins] icinga.org: icinga-web/r1.8: Added xml template caching

git at icinga.org git at icinga.org
Mon Jan 14 13:41:51 CET 2013


Module: icinga-web
Branch: r1.8
Commit: 0db473ef370f4ad5a395021c11b09d336c4d64a0
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=0db473ef370f4ad5a395021c11b09d336c4d64a0

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Tue Dec 18 12:24:37 2012 +0100

Added xml template caching

---

 .../template/CronkGridTemplateXmlParser.class.php  |   14 ++++++++++-
 .../views/System/ViewProcSuccessView.class.php     |   25 +++++++++++++------
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php b/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
index 4b51975..99d71d2 100755
--- a/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
+++ b/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
@@ -30,7 +30,7 @@ class __CronkGridTemplateXmlParserInternalCacheContainer__ {
 
 }
 
-class CronkGridTemplateXmlParser {
+class CronkGridTemplateXmlParser implements Serializable {
 
     /**
      * @var DOMDocument
@@ -70,6 +70,18 @@ class CronkGridTemplateXmlParser {
             $this->rewrite = new CronkGridTemplateXmlReplace();
         }
     }
+    public function serialize() {
+        return serialize(array(
+            "data"=>$this->data,
+            "fields"=>$this->fields
+        ));
+    }
+    public function unserialize($serialized) {
+        $data = unserialize($serialized);
+
+        $this->data = $data["data"];
+        $this->fields = $data["fields"];
+    }
 
     /**
      * Inits the dom with a file
diff --git a/app/modules/Cronks/views/System/ViewProcSuccessView.class.php b/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
index 3e7e77e..cf0acc1 100644
--- a/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
+++ b/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
@@ -54,20 +54,24 @@ class Cronks_System_ViewProcSuccessView extends CronksBaseView {
     public function executeHtml(AgaviRequestDataHolder $rd) {
 
         $this->setupHtml($rd);
+        $storage = $this->getContext()->getUser()->getNsmUser()->getStorage();
 
         try {
-            $file = $this->getTemplateFile($rd);
 
-            $template = new CronkGridTemplateXmlParser($file->getRealPath(), $this->getContext());
-            $template->parseTemplate();
+            $file = $this->getTemplateFile($rd);
+            $template = unserialize($storage->read("icinga.cronks.template.".$file));
+            if(!$template) {
+                $template = new CronkGridTemplateXmlParser($file->getRealPath(), $this->getContext());
+                $template->parseTemplate();
+                $storage->write("icinga.cronks.template".$file,serialize($template));
+            }
 
             $worker = CronkGridTemplateWorkerFactory::createWorker($template, $this->getContext());
-
             $layout_class = $template->getSectionParams('option')->getParameter('layout');
             $layout = AppKitClassUtil::createInstance($layout_class);
+            $layout->setWorker($worker);
 
             $layout->setContainer($this->getContainer());
-            $layout->setWorker($worker);
             $layout->setParameters($rd);
 
             return $layout->getLayoutContent();
@@ -80,13 +84,18 @@ class Cronks_System_ViewProcSuccessView extends CronksBaseView {
         $data = array();
         
         $jsonResult = new AppKitExtJsonDocument();
-        
+        $storage = $this->getContext()->getUser()->getNsmUser()->getStorage();
+
         try {
 
             $file = $this->getTemplateFile($rd);
+            $template = unserialize($storage->read("icinga.cronks.template.".$file));
+            if(!$template) {
+                $template = new CronkGridTemplateXmlParser($file->getRealPath(), $this->getContext());
+                $template->parseTemplate();
+                $storage->write("icinga.cronks.template".$file,serialize($template));
+            }
 
-            $template = new CronkGridTemplateXmlParser($file->getRealPath(), $this->getContext());
-            $template->parseTemplate();
             $connection = $rd->getParameter("connection","icinga");
 
             $worker = CronkGridTemplateWorkerFactory::createWorker($template, $this->getContext(), $connection);





More information about the icinga-checkins mailing list