added more caching for smarty globals

This commit is contained in:
Sebastian Grewe 2013-05-14 23:58:42 +02:00
parent 9762081d9d
commit d06b9b8db7

View File

@ -7,6 +7,7 @@ if (!defined('SECURITY'))
// Globally available variables
$debug->append('Global smarty variables', 3);
// Store some stuff in memcache prior to assigning it to Smarty
if (!$aRoundShares = $memcache->get('aRoundShares')) {
$debug->append('Fetching aRoundShares from database');
$aRoundShares = $statistics->getRoundShares();
@ -25,13 +26,18 @@ if (!$iCurrentPoolHashrate = $memcache->get('iCurrentPoolHashrate')) {
$memcache->set('iCurrentPoolHashrate', $iCurrentPoolHashrate, 60);
}
if (!$iCurrentPoolShareRate = $memcache->get('iCurrentPoolShareRate')) {
$debug->append('Fetching iCurrentPoolShareRate from database');
$iCurrentPoolShareRate = $statistics->getCurrentShareRate();
$memcache->set('iCurrentPoolShareRate', $iCurrentPoolShareRate, 60);
}
$aGlobal = array(
'userdata' => $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array(),
'slogan' => $settings->getValue('slogan'),
'websitename' => $settings->getValue('websitename'),
'ltc_usd' => $settings->getValue('btcesell'),
'hashrate' => $iCurrentPoolHashrate,
'sharerate' => $statistics->getCurrentShareRate(),
'sharerate' => $iCurrentPoolShareRate,
'workers' => $iCurrentActiveWorkers,
'roundshares' => $aRoundShares,
'statstime' => $settings->getValue('statstime'),
@ -40,9 +46,18 @@ $aGlobal = array(
'reward' => $config['reward']
);
// Append additional user information not from user table
// We don't want the session infos cached
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
// Balance should also not be cached
$aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']['id']);
// Other userdata that we can cache savely
if (!$aGlobal['userdata']['hashrate'] = $memcache->get('global_' . $_SESSION['USERDATA']['id'] . '_hashrate') ) {
$aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']);
$memcache->set('global_' . $_SESSION['USERDATA']['id'] . '_hashrate', $aGlobal['userdata']['hashrate'], 60);
}
// Make it available in Smarty
$smarty->assign('PATH', 'site_assets/' . THEME);
$smarty->assign('GLOBAL', $aGlobal);