mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-11 13:02:15 +09:00
Changed the way comment lists are removed from cache - instead of delete, key incrementing is now used.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9501 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
a69023da83
commit
441ef79f1b
4 changed files with 51 additions and 101 deletions
10
classes/cache/CacheHandler.class.php
vendored
10
classes/cache/CacheHandler.class.php
vendored
|
|
@ -10,6 +10,7 @@
|
|||
class CacheHandler extends Handler {
|
||||
|
||||
var $handler = null;
|
||||
var $keyGroupVersions = null;
|
||||
|
||||
function &getInstance($target='object') {
|
||||
return new CacheHandler($target);
|
||||
|
|
@ -36,6 +37,11 @@
|
|||
$class = 'Cache' . ucfirst($type);
|
||||
include_once sprintf('%sclasses/cache/%s.class.php', _XE_PATH_, $class);
|
||||
$this->handler = call_user_func(array($class,'getInstance'), $url);
|
||||
$this->keyGroupVersions = $this->handler->get('key_group_versions', 0);
|
||||
if(!$this->keyGroupVersions) {
|
||||
$this->keyGroupVersions = array();
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,6 +91,7 @@
|
|||
function getGroupKey($keyGroupName, $key){
|
||||
if(!$this->keyGroupVersions[$keyGroupName]){
|
||||
$this->keyGroupVersions[$keyGroupName] = 1;
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
|
||||
return $this->keyGroupVersions[$keyGroupName] . ':' . $keyGroupName . ':' . $key;
|
||||
|
|
@ -92,12 +99,11 @@
|
|||
|
||||
function invalidateGroupKey($keyGroupName){
|
||||
$this->keyGroupVersions[$keyGroupName]++;
|
||||
$this->handler->put('key_group_versions', $this->keyGroupVersions, 0);
|
||||
}
|
||||
}
|
||||
|
||||
class CacheBase{
|
||||
var $keyGroupVersions = array();
|
||||
|
||||
function get($key, $modified_time = 0){
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,12 +83,7 @@
|
|||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
|
||||
$msgCode = '';
|
||||
|
|
@ -178,12 +173,7 @@
|
|||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,16 +246,7 @@
|
|||
{
|
||||
$cache_key_newest = 'object_newest_comment_list:'.$obj->module_srl;
|
||||
$oCacheHandler->delete($cache_key_newest);
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
if(isset($cache_object) && is_array($cache_object)){
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
}elseif(!is_array($cache_object)) {
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -339,16 +330,7 @@
|
|||
{
|
||||
$cache_key_newest = 'object_newest_comment_list:'.$obj->module_srl;
|
||||
$oCacheHandler->delete($cache_key_newest);
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
if(isset($cache_object) && is_array($cache_object)){
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
}elseif(!is_array($cache_object)) {
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -417,16 +399,7 @@
|
|||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
if(isset($cache_object) && is_array($cache_object)){
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
}elseif(!is_array($cache_object)) {
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -485,16 +458,7 @@
|
|||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport())
|
||||
{
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
if(isset($cache_object) && is_array($cache_object)){
|
||||
foreach ($cache_object as $object){
|
||||
$cache_key = $object;
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
}elseif(!is_array($cache_object)) {
|
||||
$oCacheHandler->delete($cache_key);
|
||||
}
|
||||
$oCacheHandler->delete('comment_list_document_pages');
|
||||
$oCacheHandler->invalidateGroupKey('commentList');
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -222,19 +222,9 @@
|
|||
// cache controll
|
||||
$oCacheHandler = &CacheHandler::getInstance('object');
|
||||
if($oCacheHandler->isSupport()){
|
||||
$cache_key = 'object:'.$document_srl.'_'.$page;
|
||||
$object_key = 'object:'.$document_srl.'_'.$page.'_'.($is_admin ? 'Y' : 'N') .'_' . $count;
|
||||
$cache_key = $oCacheHandler->getGroupKey('commentList', $object_key);
|
||||
$output = $oCacheHandler->get($cache_key);
|
||||
$cache_object = $oCacheHandler->get('comment_list_document_pages');
|
||||
if($cache_object) {
|
||||
if(!in_array($cache_key, $cache_object)) {
|
||||
$cache_object[]=$cache_key;
|
||||
$oCacheHandler->put('comment_list_document_pages',$cache_object);
|
||||
}
|
||||
} else {
|
||||
$cache_object = array();
|
||||
$cache_object[] = $cache_key;
|
||||
$oCacheHandler->put('comment_list_document_pages',$cache_object);
|
||||
}
|
||||
}
|
||||
if(!$output){
|
||||
// get the number of comments on the document module
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue