From aa0d6e7cd80795b48e861295fe2b5a6abdfbcfa1 Mon Sep 17 00:00:00 2001 From: bnu Date: Fri, 31 Jan 2014 02:02:20 +0900 Subject: [PATCH] =?UTF-8?q?#385=20`commentList=5F{document=5Fsrl}`=20objec?= =?UTF-8?q?t=20cache=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comment/comment.controller.php | 36 ----- modules/comment/comment.model.php | 127 ++++++++---------- .../document/document.admin.controller.php | 1 - 3 files changed, 54 insertions(+), 110 deletions(-) diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index a9e918929..18e86394c 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -469,16 +469,6 @@ class commentController extends comment $output->add('comment_srl', $obj->comment_srl); - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $oCacheHandler->invalidateGroupKey('commentList_' . $document_srl); - $oCacheHandler->invalidateGroupKey('newestCommentsList'); - - $oCacheHandler->delete('object:' . $document_srl); - } - return $output; } @@ -736,14 +726,6 @@ class commentController extends comment $output->add('comment_srl', $obj->comment_srl); - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $oCacheHandler->invalidateGroupKey('commentList_' . $obj->document_srl); - $oCacheHandler->invalidateGroupKey('newestCommentsList'); - } - return $output; } @@ -872,16 +854,6 @@ class commentController extends comment $output->add('document_srl', $document_srl); - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $oCacheHandler->invalidateGroupKey('commentList_' . $document_srl); - $oCacheHandler->invalidateGroupKey('newestCommentsList'); - - $oCacheHandler->delete('object:' . $document_srl); - } - return $output; } @@ -970,14 +942,6 @@ class commentController extends comment $this->_deleteVotedComments($args); } - //remove from cache - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) - { - $oCacheHandler->invalidateGroupKey('commentList_' . $document_srl); - $oCacheHandler->invalidateGroupKey('newestCommentsList'); - } - return $output; } diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index a551e76e3..9d5439a13 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -445,97 +445,78 @@ class commentModel extends comment return; } - // cache controll - $output = false; - $oCacheHandler = CacheHandler::getInstance('object'); - if($oCacheHandler->isSupport()) + // get the number of comments on the document module + $oDocumentModel = getModel('document'); + $columnList = array('document_srl', 'module_srl', 'comment_count'); + $oDocument = $oDocumentModel->getDocument($document_srl, FALSE, TRUE, $columnList); + + // return if no doc exists. + if(!$oDocument->isExists()) { - $object_key = 'object:' . $document_srl . '_' . $page . '_' . ($is_admin ? 'Y' : 'N') . '_' . $count; - $cache_key = $oCacheHandler->getGroupKey('commentList_' . $document_srl, $object_key); - $output = $oCacheHandler->get($cache_key); + return; } - if($output === FALSE) + // return if no comment exists + if($oDocument->getCommentCount() < 1) { - // get the number of comments on the document module - $oDocumentModel = getModel('document'); - $columnList = array('document_srl', 'module_srl', 'comment_count'); - $oDocument = $oDocumentModel->getDocument($document_srl, FALSE, TRUE, $columnList); + return; + } - // return if no doc exists. - if(!$oDocument->isExists()) + // get a list of comments + $module_srl = $oDocument->get('module_srl'); + + if(!$count) + { + $comment_config = $this->getCommentConfig($module_srl); + $comment_count = $comment_config->comment_count; + if(!$comment_count) { - return; + $comment_count = 50; } + } + else + { + $comment_count = $count; + } - // return if no comment exists - if($oDocument->getCommentCount() < 1) - { - return; - } + // get a very last page if no page exists + if(!$page) + { + $page = (int) ( ($oDocument->getCommentCount() - 1) / $comment_count) + 1; + } - // get a list of comments - $module_srl = $oDocument->get('module_srl'); + // get a list of comments + $args = new stdClass(); + $args->document_srl = $document_srl; + $args->list_count = $comment_count; + $args->page = $page; + $args->page_count = 10; - if(!$count) - { - $comment_config = $this->getCommentConfig($module_srl); - $comment_count = $comment_config->comment_count; - if(!$comment_count) - { - $comment_count = 50; - } - } - else - { - $comment_count = $count; - } + //check if module is using validation system + $oCommentController = getController('comment'); + $using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); + if($using_validation) + { + $args->status = 1; + } - // get a very last page if no page exists - if(!$page) - { - $page = (int) ( ($oDocument->getCommentCount() - 1) / $comment_count) + 1; - } + $output = executeQueryArray('comment.getCommentPageList', $args); - // get a list of comments - $args = new stdClass(); - $args->document_srl = $document_srl; - $args->list_count = $comment_count; - $args->page = $page; - $args->page_count = 10; - - //check if module is using validation system - $oCommentController = getController('comment'); - $using_validation = $oCommentController->isModuleUsingPublishValidation($module_srl); - if($using_validation) - { - $args->status = 1; - } + // return if an error occurs in the query results + if(!$output->toBool()) + { + return; + } + // insert data into CommentPageList table if the number of results is different from stored comments + if(!$output->data) + { + $this->fixCommentList($oDocument->get('module_srl'), $document_srl); $output = executeQueryArray('comment.getCommentPageList', $args); - - // return if an error occurs in the query results if(!$output->toBool()) { return; } - - // insert data into CommentPageList table if the number of results is different from stored comments - if(!$output->data) - { - $this->fixCommentList($oDocument->get('module_srl'), $document_srl); - $output = executeQueryArray('comment.getCommentPageList', $args); - if(!$output->toBool()) - { - return; - } - } - - //insert in cache - if($oCacheHandler->isSupport()) - { - $oCacheHandler->put($cache_key, $output); - } } return $output; diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php index 7d185dc2b..922d944f8 100644 --- a/modules/document/document.admin.controller.php +++ b/modules/document/document.admin.controller.php @@ -453,7 +453,6 @@ class documentAdminController extends document { $cache_key_item = 'document_item:'.$document_srl; $oCacheHandler->delete($cache_key_item); - $oCacheHandler->invalidateGroupKey('commentList_' . $document_srl); } } }