From b29cf1fb679abf72ff0ffa5cc3b8aaeaadd315b5 Mon Sep 17 00:00:00 2001 From: bnu Date: Sun, 5 Jan 2014 02:01:04 +0900 Subject: [PATCH] =?UTF-8?q?#242=20document=20item=EC=9D=98=20object=20cach?= =?UTF-8?q?e=20=EC=A0=95=EB=A6=AC.=20-=20=EC=9D=BC=EB=B6=80=20=EA=B8=B0?= =?UTF-8?q?=EB=A1=9D=EC=84=B1=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20?= =?UTF-8?q?=EC=A0=9C=EC=99=B8=ED=95=98=EA=B3=A0=20object=20cache=EB=A5=BC?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=A8?= =?UTF-8?q?=EA=B3=BC=20=EC=9D=B4=EC=97=90=20=EB=94=B0=EB=9D=BC=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EA=B0=92=EC=9D=B4=20=EB=B3=80=EA=B2=BD=EB=90=A0=20?= =?UTF-8?q?=EB=95=8C=20cache=EB=A5=BC=20=EA=B0=B1=EC=8B=A0=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD.?= =?UTF-8?q?=20=20=20-=20readed=5Fcount,=20comment=5Fcount,=20voted=5Fcount?= =?UTF-8?q?,=20blamed=5Fcount,=20trackback=5Fcount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/document.admin.controller.php | 8 +-- modules/document/document.controller.php | 38 ++----------- modules/document/document.item.php | 57 +++++++++++++------ 3 files changed, 45 insertions(+), 58 deletions(-) diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index a3a72c291..1859dd0cd 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -195,9 +195,7 @@ class documentAdminController extends document { foreach($document_srl_list as $document_srl) { - $cache_key = 'object:'.$document_srl; - $oCacheHandler->delete($cache_key); - $cache_key_item = 'object_document_item:'.$document_srl; + $cache_key_item = 'document_item:'.$document_srl; $oCacheHandler->delete($cache_key_item); } } @@ -453,9 +451,7 @@ class documentAdminController extends document { foreach($document_srl_list as $document_srl) { - $cache_key = 'object:'.$document_srl; - $oCacheHandler->delete($cache_key); - $cache_key_item = 'object_document_item:'.$document_srl; + $cache_key_item = 'document_item:'.$document_srl; $oCacheHandler->delete($cache_key_item); $oCacheHandler->invalidateGroupKey('commentList_' . $document_srl); } diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 3250d0475..a457b49a7 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -320,13 +320,6 @@ class documentController extends document $this->addGrant($obj->document_srl); $output->add('document_srl',$obj->document_srl); $output->add('category_srl',$obj->category_srl); - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $cache_key = 'object:'.$obj->document_srl; - $oCacheHandler->delete($cache_key); - } return $output; } @@ -538,10 +531,8 @@ class documentController extends document $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { - $cache_key = 'object:'.$obj->document_srl; - $oCacheHandler->delete($cache_key); //remove document item from cache - $cache_key = 'object_document_item:'.$obj->document_srl; + $cache_key = 'document_item:'.$obj->document_srl; $oCacheHandler->delete($cache_key); } @@ -632,9 +623,7 @@ class documentController extends document $oCacheHandler = CacheHandler::getInstance('object'); if($oCacheHandler->isSupport()) { - $cache_key = 'object:'.$document_srl; - $oCacheHandler->delete($cache_key); - $cache_key = 'object_document_item:'.$document_srl; + $cache_key = 'document_item:'.$document_srl; $oCacheHandler->delete($cache_key); } @@ -799,6 +788,7 @@ class documentController extends document // Call a trigger when the read count is updated (after) $output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); if(!$output->toBool()) return $output; + // Pass if read count is increaded on the session information if($_SESSION['readed_document'][$document_srl]) return false; @@ -818,18 +808,9 @@ class documentController extends document $args = new stdClass; $args->document_srl = $document_srl; $output = executeQuery('document.updateReadedCount', $args); + // Register session $_SESSION['readed_document'][$document_srl] = true; - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $cache_key = 'object:'.$document_srl; - $oCacheHandler->delete($cache_key); - //remove document item from cache - $cache_key = 'object_document_item:'.$document_srl; - $oCacheHandler->delete($cache_key); - } return TRUE; } @@ -1214,17 +1195,6 @@ class documentController extends document $args->last_updater = $last_updater; } - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $cache_key = 'object:'.$document_srl; - $oCacheHandler->delete($cache_key); - //remove document item from cache - $cache_key = 'object_document_item:'.$document_srl; - $oCacheHandler->delete($cache_key); - } - return executeQuery('document.updateCommentCount', $args); } diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 5cfa4492b..c854af04e 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -78,24 +78,48 @@ class documentItem extends Object // cache controll $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport() && !count($this->columnList)) + if($oCacheHandler->isSupport()) { - $cache_key = 'object_document_item:'.$this->document_srl; - $output = $oCacheHandler->get($cache_key); + $cache_key = 'document_item:' . $this->document_srl; + $document_item = $oCacheHandler->get($cache_key); + if($document_item) + { + $document_item = (object)$document_item->getVariables(); + $this->columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count'); + } + else + { + $this->columnList = array(); + } } - if(!$output) + + $args = new stdClass(); + $args->document_srl = $this->document_srl; + $output = executeQuery('document.getDocument', $args, $this->columnList); + + if(!$document_item) { - $args = new stdClass(); - $args->document_srl = $this->document_srl; - $output = executeQuery('document.getDocument', $args, $this->columnList); - //insert in cache - if($output->data->document_srl && $oCacheHandler->isSupport()) - $oCacheHandler->put($cache_key,$output); + $document_item = $output->data; + } + else + { + $document_item->readed_count = $output->data->readed_count; + $document_item->voted_count = $output->data->voted_count; + $document_item->blamed_count = $output->data->blamed_count; + $document_item->comment_count = $output->data->comment_count; + $document_item->trackback_count = $output->data->trackback_count; + } + + $this->setAttribute($document_item, $load_extra_vars); + + //insert in cache + if($this->document_srl && $oCacheHandler->isSupport()) + { + $oCacheHandler->put($cache_key, $this); } - $this->setAttribute($output->data,$load_extra_vars); } - function setAttribute($attribute,$load_extra_vars=true) + function setAttribute($attribute, $load_extra_vars=true) { if(!$attribute->document_srl) { @@ -105,15 +129,12 @@ class documentItem extends Object $this->document_srl = $attribute->document_srl; $this->lang_code = $attribute->lang_code; $this->adds($attribute); + // Tags if($this->get('tags')) { - $tags = explode(',',$this->get('tags')); - $tag_count = count($tags); - for($i=0;$i<$tag_count;$i++) - { - if(trim($tags[$i])) $tag_list[] = trim($tags[$i]); - } + $tag_list = explode(',', $this->get('tags')); + $tag_list = array_map('trim', $tag_list); $this->add('tag_list', $tag_list); }