added more caching for smarty globals
This commit is contained in:
parent
9762081d9d
commit
d06b9b8db7
@ -7,6 +7,7 @@ if (!defined('SECURITY'))
|
|||||||
// Globally available variables
|
// Globally available variables
|
||||||
$debug->append('Global smarty variables', 3);
|
$debug->append('Global smarty variables', 3);
|
||||||
|
|
||||||
|
// Store some stuff in memcache prior to assigning it to Smarty
|
||||||
if (!$aRoundShares = $memcache->get('aRoundShares')) {
|
if (!$aRoundShares = $memcache->get('aRoundShares')) {
|
||||||
$debug->append('Fetching aRoundShares from database');
|
$debug->append('Fetching aRoundShares from database');
|
||||||
$aRoundShares = $statistics->getRoundShares();
|
$aRoundShares = $statistics->getRoundShares();
|
||||||
@ -25,13 +26,18 @@ if (!$iCurrentPoolHashrate = $memcache->get('iCurrentPoolHashrate')) {
|
|||||||
$memcache->set('iCurrentPoolHashrate', $iCurrentPoolHashrate, 60);
|
$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(
|
$aGlobal = array(
|
||||||
'userdata' => $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array(),
|
|
||||||
'slogan' => $settings->getValue('slogan'),
|
'slogan' => $settings->getValue('slogan'),
|
||||||
'websitename' => $settings->getValue('websitename'),
|
'websitename' => $settings->getValue('websitename'),
|
||||||
'ltc_usd' => $settings->getValue('btcesell'),
|
'ltc_usd' => $settings->getValue('btcesell'),
|
||||||
'hashrate' => $iCurrentPoolHashrate,
|
'hashrate' => $iCurrentPoolHashrate,
|
||||||
'sharerate' => $statistics->getCurrentShareRate(),
|
'sharerate' => $iCurrentPoolShareRate,
|
||||||
'workers' => $iCurrentActiveWorkers,
|
'workers' => $iCurrentActiveWorkers,
|
||||||
'roundshares' => $aRoundShares,
|
'roundshares' => $aRoundShares,
|
||||||
'statstime' => $settings->getValue('statstime'),
|
'statstime' => $settings->getValue('statstime'),
|
||||||
@ -40,9 +46,18 @@ $aGlobal = array(
|
|||||||
'reward' => $config['reward']
|
'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']);
|
$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
|
// Make it available in Smarty
|
||||||
$smarty->assign('PATH', 'site_assets/' . THEME);
|
$smarty->assign('PATH', 'site_assets/' . THEME);
|
||||||
$smarty->assign('GLOBAL', $aGlobal);
|
$smarty->assign('GLOBAL', $aGlobal);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user