mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Improve shared caching and invalidation of member points
This commit is contained in:
parent
5b22b0399c
commit
e370ba680f
3 changed files with 31 additions and 22 deletions
|
|
@ -12,6 +12,16 @@ class point extends ModuleObject
|
|||
*/
|
||||
protected static $_config = null;
|
||||
|
||||
/**
|
||||
* @brief Module configuration cache
|
||||
*/
|
||||
protected static $_module_config_cache = array();
|
||||
|
||||
/**
|
||||
* @brief Member point cache
|
||||
*/
|
||||
protected static $_member_point_cache = array();
|
||||
|
||||
/**
|
||||
* @brief Shortcut to getting module configuration
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@
|
|||
*/
|
||||
class pointController extends point
|
||||
{
|
||||
/**
|
||||
* @brief Cache module point config
|
||||
*/
|
||||
protected static $_module_point_config = array();
|
||||
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
|
|
@ -691,6 +686,7 @@ class pointController extends point
|
|||
FileHandler::writeFile($cache_filename, $point);
|
||||
|
||||
getController('member')->_clearMemberCache($member_srl);
|
||||
unset(self::$_member_point_cache[$member_srl]);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -715,11 +711,11 @@ class pointController extends point
|
|||
|
||||
if ($module_srl)
|
||||
{
|
||||
if (!isset(self::$_module_point_config[$module_srl]))
|
||||
if (!isset(self::$_module_config_cache[$module_srl]))
|
||||
{
|
||||
self::$_module_point_config[$module_srl] = $oModuleModel->getModulePartConfig('point', $module_srl);
|
||||
self::$_module_config_cache[$module_srl] = $oModuleModel->getModulePartConfig('point', $module_srl);
|
||||
}
|
||||
$module_config = self::$_module_point_config[$module_srl];
|
||||
$module_config = self::$_module_config_cache[$module_srl];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
class pointModel extends point
|
||||
{
|
||||
var $pointList = array();
|
||||
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
|
|
@ -36,29 +34,34 @@ class pointModel extends point
|
|||
$member_srl = abs($member_srl);
|
||||
|
||||
// Get from instance memory
|
||||
if(!$from_db && $this->pointList[$member_srl]) return $this->pointList[$member_srl];
|
||||
if (!$from_db && isset(self::$_member_point_cache[$member_srl])
|
||||
{
|
||||
return self::$_member_point_cache[$member_srl];
|
||||
}
|
||||
|
||||
// Get from file cache
|
||||
$path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s',getNumberingPath($member_srl));
|
||||
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
|
||||
|
||||
if(!$from_db && file_exists($cache_filename))
|
||||
return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
|
||||
$cache_path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
|
||||
$cache_filename = sprintf('%s%d.cache.txt', $cache_path, $member_srl);
|
||||
if (!$from_db && file_exists($cache_filename))
|
||||
{
|
||||
return self::$_member_point_cache[$member_srl] = trim(FileHandler::readFile($cache_filename));
|
||||
}
|
||||
|
||||
// Get from the DB
|
||||
$args = new stdClass;
|
||||
$args->member_srl = $member_srl;
|
||||
$output = executeQuery('point.getPoint', $args);
|
||||
|
||||
if(isset($output->data->member_srl))
|
||||
if (isset($output->data->member_srl))
|
||||
{
|
||||
$point = (int)$output->data->point;
|
||||
$this->pointList[$member_srl] = $point;
|
||||
if(!is_dir($path)) FileHandler::makeDir($path);
|
||||
$point = intval($output->data->point);
|
||||
self::$_member_point_cache[$member_srl] = $point;
|
||||
FileHandler::writeFile($cache_filename, $point);
|
||||
return $point;
|
||||
}
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue