Update references to CacheHandler in document module

This commit is contained in:
Kijin Sung 2016-04-18 01:42:33 +09:00
parent 2f234dfad1
commit 2e98962264
4 changed files with 47 additions and 135 deletions

View file

@ -218,15 +218,11 @@ class documentAdminController extends document
} }
$oDB->commit(); $oDB->commit();
//remove from cache //remove from cache
$oCacheHandler = CacheHandler::getInstance('object'); foreach ($document_srl_list as $document_srl)
if($oCacheHandler->isSupport())
{ {
foreach($document_srl_list as $document_srl) Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document_srl) . $document_srl);
{
$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key_item);
}
} }
return new Object(); return new Object();
} }
@ -472,18 +468,11 @@ class documentAdminController extends document
$document_srl_list[] = $oDocument->document_srl; $document_srl_list[] = $oDocument->document_srl;
} }
} }
//remove from cache //remove from cache
$oCacheHandler = CacheHandler::getInstance('object'); foreach ($document_srl_list as $document_srl)
if($oCacheHandler->isSupport())
{ {
if(is_array($document_srl_list)) Rhymix\Framework\Cache::delete('document_item:'. getNumberingPath($document_srl) . $document_srl);
{
foreach($document_srl_list as $document_srl)
{
$cache_key_item = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key_item);
}
}
} }
return $output; return $output;
} }
@ -690,13 +679,7 @@ class documentAdminController extends document
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
} }
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); Rhymix\Framework\Cache::delete("module_document_extra_keys:$module_srl", 'site_and_module');
if($oCacheHandler->isSupport())
{
$object_key = 'module_document_extra_keys:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
} }
/** /**

View file

@ -775,15 +775,9 @@ class documentController extends document
FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
$output->add('document_srl',$obj->document_srl); $output->add('document_srl',$obj->document_srl);
//remove from cache //remove from cache
$oCacheHandler = CacheHandler::getInstance('object'); Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl);
if($oCacheHandler->isSupport())
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl;
$oCacheHandler->delete($cache_key);
}
return $output; return $output;
} }
@ -919,13 +913,7 @@ class documentController extends document
$oDB->commit(); $oDB->commit();
//remove from cache //remove from cache
$oCacheHandler = CacheHandler::getInstance('object'); Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
if($oCacheHandler->isSupport())
{
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
return $output; return $output;
} }
@ -1080,13 +1068,7 @@ class documentController extends document
$oDB->commit(); $oDB->commit();
// Clear cache // Clear cache
$oCacheHandler = CacheHandler::getInstance('object'); Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl);
if($oCacheHandler->isSupport())
{
$cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
$oCacheHandler->delete($cache_key);
}
return $output; return $output;
} }
@ -1162,13 +1144,8 @@ class documentController extends document
$oDB->commit(); $oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object'); //remove document item from cache
if($oCacheHandler->isSupport()) Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
// Register session // Register session
if(!$_SESSION['banned_document'][$document_srl] && Context::getSessionStatus()) if(!$_SESSION['banned_document'][$document_srl] && Context::getSessionStatus())
@ -1219,14 +1196,7 @@ class documentController extends document
$output = executeQuery('document.updateDocumentExtraVar', $obj); $output = executeQuery('document.updateDocumentExtraVar', $obj);
} }
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); Rhymix\Framework\Cache::delete("module_document_extra_keys:$module_srl", 'site_and_module');
if($oCacheHandler->isSupport())
{
$object_key = 'module_document_extra_keys:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
return $output; return $output;
} }
@ -1282,14 +1252,7 @@ class documentController extends document
$oDB->commit(); $oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); Rhymix\Framework\Cache::delete("module_document_extra_keys:$module_srl", 'site_and_module');
if($oCacheHandler->isSupport())
{
$object_key = 'module_document_extra_keys:'.$module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$oCacheHandler->delete($cache_key);
}
return new Object(); return new Object();
} }
@ -1442,13 +1405,8 @@ class documentController extends document
$oDB->commit(); $oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object'); //remove document item from cache
if($oCacheHandler->isSupport()) Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
// Return result // Return result
$output = new Object(); $output = new Object();
@ -1617,13 +1575,8 @@ class documentController extends document
$args->update_order = -1*getNextSequence(); $args->update_order = -1*getNextSequence();
$args->last_updater = $last_updater; $args->last_updater = $last_updater;
$oCacheHandler = CacheHandler::getInstance('object'); // remove document item from cache
if($oCacheHandler->isSupport()) Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
} }
return executeQuery('document.updateCommentCount', $args); return executeQuery('document.updateCommentCount', $args);
@ -1641,13 +1594,8 @@ class documentController extends document
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$args->trackback_count = $trackback_count; $args->trackback_count = $trackback_count;
$oCacheHandler = CacheHandler::getInstance('object'); // remove document item from cache
if($oCacheHandler->isSupport()) Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
return executeQuery('document.updateTrackbackCount', $args); return executeQuery('document.updateTrackbackCount', $args);
} }
@ -1752,27 +1700,25 @@ class documentController extends document
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
$this->makeCategoryFile($category_info->module_srl); $this->makeCategoryFile($category_info->module_srl);
// remvove cache
$oCacheHandler = CacheHandler::getInstance('object'); // remove cache
if($oCacheHandler->isSupport()) $page = 0;
while(true)
{ {
$page = 0; $args = new stdClass();
while(true) { $args->category_srl = $category_srl;
$args = new stdClass(); $args->list_count = 100;
$args->category_srl = $category_srl; $args->page = ++$page;
$args->list_count = 100; $output = executeQuery('document.getDocumentList', $args, array('document_srl'));
$args->page = ++$page;
$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
if($output->data == array()) if($output->data == array())
break; {
break;
}
foreach($output->data as $val) foreach($output->data as $val)
{ {
//remove document item from cache Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($val->document_srl) . $val->document_srl);
$cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl;
$oCacheHandler->delete($cache_key);
}
} }
} }

View file

@ -82,29 +82,23 @@ class documentItem extends Object
$this->columnList = array(); $this->columnList = array();
// cache controll // cache controll
$oCacheHandler = CacheHandler::getInstance('object'); $cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
if($oCacheHandler->isSupport()) $document_item = Rhymix\Framework\Cache::get($cache_key);
if($document_item)
{ {
$cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl; $columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
$document_item = $oCacheHandler->get($cache_key);
if($document_item !== false)
{
$columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
}
} }
$args = new stdClass(); $args = new stdClass();
$args->document_srl = $this->document_srl; $args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args, $columnList); $output = executeQuery('document.getDocument', $args, $columnList);
if($document_item === false) if(!$document_item)
{ {
$document_item = $output->data; $document_item = $output->data;
if($document_item)
//insert in cache
if($document_item && $oCacheHandler->isSupport())
{ {
$oCacheHandler->put($cache_key, $document_item); Rhymix\Framework\Cache::set($cache_key, $document_item);
} }
} }
else else

View file

@ -370,18 +370,10 @@ class documentModel extends document
{ {
if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl])) if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
{ {
$keys = false; $keys = Rhymix\Framework\Cache::get("module_document_extra_keys:$module_srl", 'site_and_module');
$oCacheHandler = CacheHandler::getInstance('object', null, true);
if($oCacheHandler->isSupport())
{
$object_key = 'module_document_extra_keys:' . $module_srl;
$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
$keys = $oCacheHandler->get($cache_key);
}
$oExtraVar = ExtraVar::getInstance($module_srl); $oExtraVar = ExtraVar::getInstance($module_srl);
if($keys === false) if(!$keys)
{ {
$obj = new stdClass(); $obj = new stdClass();
$obj->module_srl = $module_srl; $obj->module_srl = $module_srl;
@ -437,10 +429,7 @@ class documentModel extends document
$keys = $oExtraVar->getExtraVars(); $keys = $oExtraVar->getExtraVars();
if(!$keys) $keys = array(); if(!$keys) $keys = array();
if($oCacheHandler->isSupport()) Rhymix\Framework\Cache::set("module_document_extra_keys:$module_srl", $keys, 0, 'site_and_module');
{
$oCacheHandler->put($cache_key, $keys);
}
} }