Fix #785 excessive use of cache by counter module

This commit is contained in:
Kijin Sung 2017-04-14 16:31:49 +09:00
parent f7d19ea47c
commit fe489420ad

View file

@ -25,25 +25,21 @@ class counterModel extends counter
*/
function isLogged($site_srl = 0)
{
$args = new stdClass();
$args->regdate = date('Ymd');
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->site_srl = $site_srl;
$iplogged = false;
$cache_key = 'counter:' . $site_srl . '_' . str_replace(array('.', ':'), '-', $args->ipaddress);
$group_key = 'counterIpLogged_' . $args->regdate;
$iplogged = Rhymix\Framework\Cache::get($group_key . ':' . $cache_key);
if(!$iplogged)
$date = date('Ymd');
if (isset($_SESSION['counter_logged'][$date]) && $_SESSION['counter_logged'][$date])
{
$output = executeQuery('counter.getCounterLog', $args);
if($output->data->count) $iplogged = TRUE;
return true;
}
if($iplogged)
$args = new stdClass();
$args->regdate = $date;
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
$args->site_srl = $site_srl;
$output = executeQuery('counter.getCounterLog', $args);
$iplogged = $output->data->count ? true : false;
if ($iplogged)
{
Rhymix\Framework\Cache::set($group_key . ':' . $cache_key, $iplogged, 0, true);
$_SESSION['counter_logged'][$date] = true;
}
return $iplogged;