Comment caching improvements.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9789 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-11-02 17:13:36 +00:00
parent 97470e4d40
commit 41584ccd58
4 changed files with 24 additions and 22 deletions

View file

@ -79,13 +79,6 @@
$oDB->commit();
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
}
$msgCode = '';
if($isTrash == 'true') $msgCode = 'success_trashed';
else $msgCode = 'success_deleted';
@ -169,11 +162,13 @@
if(!$output->toBool()) return $output;
$output = executeQuery('comment.deleteModuleCommentsList', $args);
//remove from cache
//remove from cache
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
// Invalidate newest comments. Per document cache is invalidated inside document admin controller.
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;
}

View file

@ -244,7 +244,8 @@
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
$oCacheHandler->invalidateGroupKey('commentList_' . $document_srl);
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;
}
@ -326,7 +327,8 @@
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
$oCacheHandler->invalidateGroupKey('commentList_' . $obj->document_srl);
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;
}
@ -395,7 +397,8 @@
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
$oCacheHandler->invalidateGroupKey('commentList_' . $document_srl);
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;
}
@ -454,7 +457,8 @@
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('commentList');
$oCacheHandler->invalidateGroupKey('commentList_' . $document_srl);
$oCacheHandler->invalidateGroupKey('newestCommentsList');
}
return $output;

View file

@ -175,6 +175,7 @@
/**
* @brief get the comment in corresponding with mid.
* TODO add commentItems to cache too
**/
function getNewestCommentList($obj, $columnList = array()) {
if($obj->mid) {
@ -190,7 +191,7 @@
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()){
$object_key = 'object_newest_comment_list:'.$obj->module_srl;
$cache_key = $oCacheHandler->getGroupKey('commentList', $object_key);
$cache_key = $oCacheHandler->getGroupKey('newestCommentsList', $object_key);
$output = $oCacheHandler->get($cache_key);
}
if(!$output){
@ -220,17 +221,18 @@
* @brief get a comment list of the doc in corresponding woth document_srl.
**/
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) {
if(!isset($document_srl)) return;
// cache controll
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()){
$object_key = 'object:'.$document_srl.'_'.$page.'_'.($is_admin ? 'Y' : 'N') .'_' . $count;
$cache_key = $oCacheHandler->getGroupKey('commentList', $object_key);
$output = $oCacheHandler->get($cache_key);
}
$oCacheHandler = &CacheHandler::getInstance('object');
if($oCacheHandler->isSupport()){
$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);
}
if(!$output){
// get the number of comments on the document module
// get the number of comments on the document module
$oDocumentModel = &getModel('document');
$columnList = array('document_srl', 'module_srl', 'comment_count');
$columnList = array('document_srl', 'module_srl', 'comment_count');
$oDocument = $oDocumentModel->getDocument($document_srl, false, true, $columnList);
// return if no doc exists.
if(!$oDocument->isExists()) return;

View file

@ -321,6 +321,7 @@
$oCacheHandler->delete($cache_key);
$cache_key_item = 'object_document_item:'.$document_srl;
$oCacheHandler->delete($cache_key_item);
$oCacheHandler->invalidateGroupKey('commentList_' . $document_srl);
}
$oCacheHandler->invalidateGroupKey('documentList');
}