mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 09:27:25 +00:00
use memcache object method instead of low level method (#234)
This commit is contained in:
parent
8c85b95220
commit
1e06755a74
6 changed files with 37 additions and 41 deletions
|
@ -4,7 +4,7 @@ function send_email_alert($name, $title, $message, $t=10)
|
|||
{
|
||||
// debuglog(__FUNCTION__);
|
||||
|
||||
$last = memcache_get(controller()->memcache->memcache, "last_email_sent_$name");
|
||||
$last = controller()->memcache->get("last_email_sent_$name");
|
||||
if($last + $t*60 > time()) return;
|
||||
|
||||
debuglog("mail('".YAAMP_ADMIN_EMAIL."', $title, ...)");
|
||||
|
@ -12,7 +12,7 @@ function send_email_alert($name, $title, $message, $t=10)
|
|||
$b = mail(YAAMP_ADMIN_EMAIL, $title, $message);
|
||||
if(!$b) debuglog('error sending email');
|
||||
|
||||
memcache_set(controller()->memcache->memcache, "last_email_sent_$name", time());
|
||||
controller()->memcache->set("last_email_sent_$name", time());
|
||||
}
|
||||
|
||||
function dos_filesize($fn)
|
||||
|
|
|
@ -20,8 +20,7 @@ class ApiController extends CommonController
|
|||
return;
|
||||
}
|
||||
|
||||
$memcache = controller()->memcache->memcache;
|
||||
$json = memcache_get($memcache, "api_status");
|
||||
$json = controller()->memcache->get("api_status");
|
||||
|
||||
if (!empty($json)) {
|
||||
echo $json;
|
||||
|
@ -97,7 +96,7 @@ class ApiController extends CommonController
|
|||
$json = json_encode($stats);
|
||||
echo $json;
|
||||
|
||||
memcache_set($memcache, "api_status", $json, MEMCACHE_COMPRESSED, 30);
|
||||
controller()->memcache->set("api_status", $json, MEMCACHE_COMPRESSED, 30);
|
||||
}
|
||||
|
||||
public function actionCurrencies()
|
||||
|
@ -112,9 +111,7 @@ class ApiController extends CommonController
|
|||
return;
|
||||
}
|
||||
|
||||
$memcache = controller()->memcache->memcache;
|
||||
|
||||
$json = memcache_get($memcache, "api_currencies");
|
||||
$json = controller()->memcache->get("api_currencies");
|
||||
if (empty($json)) {
|
||||
|
||||
$data = array();
|
||||
|
@ -186,7 +183,7 @@ class ApiController extends CommonController
|
|||
$data[$symbol]['symbol'] = $coin->symbol2;
|
||||
}
|
||||
$json = json_encode($data);
|
||||
memcache_set($memcache, "api_currencies", $json, MEMCACHE_COMPRESSED, 15);
|
||||
controller()->memcache->set("api_currencies", $json, MEMCACHE_COMPRESSED, 15);
|
||||
}
|
||||
|
||||
echo str_replace("},","},\n", $json);
|
||||
|
|
|
@ -415,7 +415,7 @@ class SiteController extends CommonController
|
|||
$algo = user()->getState('yaamp-algo');
|
||||
$memcache = controller()->memcache->memcache;
|
||||
$memkey = $algo.'_'.str_replace('/','_',$partial);
|
||||
$html = memcache_get($memcache, $memkey);
|
||||
$html = controller()->memcache->get($memkey);
|
||||
|
||||
if (!empty($html)) {
|
||||
echo $html;
|
||||
|
@ -428,7 +428,7 @@ class SiteController extends CommonController
|
|||
$html = ob_get_clean();
|
||||
echo $html;
|
||||
|
||||
memcache_set($memcache, $memkey, $html, MEMCACHE_COMPRESSED, $cachetime);
|
||||
controller()->memcache->set($memkey, $html, MEMCACHE_COMPRESSED, $cachetime);
|
||||
}
|
||||
|
||||
// Pool Status : public right panel with all algos and live stats
|
||||
|
|
|
@ -507,8 +507,8 @@ function cronstate2text($state)
|
|||
}
|
||||
}
|
||||
|
||||
//$state_block = memcache_get($this->memcache->memcache, 'cronjob_block_state');
|
||||
$state_main = memcache_get($this->memcache->memcache, 'cronjob_main_state');
|
||||
//$state_block = $this->memcache->get('cronjob_block_state');
|
||||
$state_main = $this->memcache->get('cronjob_main_state');
|
||||
$btc = getdbosql('db_coins', "symbol='BTC'");
|
||||
if (!$btc) $btc = json_decode('{"id": 6, "balance": 0}');
|
||||
|
||||
|
@ -517,24 +517,24 @@ for($i=0; $i<10; $i++)
|
|||
{
|
||||
// if($i != $state_block-1 && $state_block>0)
|
||||
// {
|
||||
// $state = memcache_get($this->memcache->memcache, "cronjob_block_state_$i");
|
||||
// $state = $this->memcache->get("cronjob_block_state_$i");
|
||||
// if($state) echo "block $i ";
|
||||
// }
|
||||
|
||||
if($i != $state_main-1 && $state_main>0)
|
||||
{
|
||||
$state = memcache_get($this->memcache->memcache, "cronjob_main_state_$i");
|
||||
$state = $this->memcache->get("cronjob_main_state_$i");
|
||||
if($state) echo "main $i ";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</span>';
|
||||
|
||||
$block_time = sectoa(time()-memcache_get($this->memcache->memcache, "cronjob_block_time_start"));
|
||||
$loop2_time = sectoa(time()-memcache_get($this->memcache->memcache, "cronjob_loop2_time_start"));
|
||||
$main_time2 = sectoa(time()-memcache_get($this->memcache->memcache, "cronjob_main_time_start"));
|
||||
$block_time = sectoa(time()-$this->memcache->get("cronjob_block_time_start"));
|
||||
$loop2_time = sectoa(time()-$this->memcache->get("cronjob_loop2_time_start"));
|
||||
$main_time2 = sectoa(time()-$this->memcache->get("cronjob_main_time_start"));
|
||||
|
||||
$main_time = sectoa(memcache_get($this->memcache->memcache, "cronjob_main_time"));
|
||||
$main_time = sectoa($this->memcache->get("cronjob_main_time"));
|
||||
$main_text = cronstate2text($state_main);
|
||||
|
||||
echo "*** main ($main_time) $state_main $main_text ($main_time2), loop2 ($loop2_time), block ($block_time)<br>";
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
echo "<a href='/site/memcached'>refresh</a><br>";
|
||||
|
||||
$memcache = controller()->memcache->memcache;
|
||||
$a = memcache_get($this->memcache->memcache, 'url-map');
|
||||
$a = controller()->memcache->memcache->get( 'url-map');
|
||||
|
||||
function printStats($stat)
|
||||
{
|
||||
|
@ -51,7 +50,7 @@ function cmp($a, $b)
|
|||
if (!empty($a))
|
||||
foreach($a as $url=>$n)
|
||||
{
|
||||
$d = memcache_get($this->memcache->memcache, "$url-time");
|
||||
$d = $this->memcache->get("$url-time");
|
||||
$avg = $d/$n;
|
||||
|
||||
$res[] = array($url, $n, $d, $avg);
|
||||
|
|
|
@ -18,7 +18,7 @@ class CronjobController extends CommonController
|
|||
|
||||
$uptime = exec('uptime');
|
||||
|
||||
$apache_locked = memcache_get($this->memcache->memcache, 'apache_locked');
|
||||
$apache_locked = $this->memcache->get('apache_locked');
|
||||
if($apache_locked) return;
|
||||
|
||||
$b = preg_match('/load average: (.*)$/', $uptime, $m);
|
||||
|
@ -52,7 +52,7 @@ class CronjobController extends CommonController
|
|||
|
||||
$this->monitorApache();
|
||||
|
||||
$last_complete = memcache_get($this->memcache->memcache, "cronjob_block_time_start");
|
||||
$last_complete = $this->memcache->get("cronjob_block_time_start");
|
||||
if($last_complete+(5*60) < time())
|
||||
dborun("update jobs set active=false");
|
||||
|
||||
|
@ -62,7 +62,7 @@ class CronjobController extends CommonController
|
|||
BackendProcessList();
|
||||
BackendBlocksUpdate();
|
||||
|
||||
memcache_set($this->memcache->memcache, "cronjob_block_time_start", time());
|
||||
$this->memcache->set("cronjob_block_time_start", time());
|
||||
// debuglog(__METHOD__);
|
||||
}
|
||||
|
||||
|
@ -82,21 +82,21 @@ class CronjobController extends CommonController
|
|||
|
||||
MonitorBTC();
|
||||
|
||||
$last = memcache_get($this->memcache->memcache, 'last_renting_payout2');
|
||||
$last = $this->memcache->get('last_renting_payout2');
|
||||
if($last + 5*60 < time())
|
||||
{
|
||||
memcache_set($this->memcache->memcache, 'last_renting_payout2', time());
|
||||
$this->memcache->set('last_renting_payout2', time());
|
||||
BackendRentingPayout();
|
||||
}
|
||||
|
||||
$last = memcache_get($this->memcache->memcache, 'last_stats2');
|
||||
$last = $this->memcache->get('last_stats2');
|
||||
if($last + 5*60 < time())
|
||||
{
|
||||
memcache_set($this->memcache->memcache, 'last_stats2', time());
|
||||
$this->memcache->set('last_stats2', time());
|
||||
BackendStatsUpdate2();
|
||||
}
|
||||
|
||||
memcache_set($this->memcache->memcache, "cronjob_loop2_time_start", time());
|
||||
$this->memcache->set("cronjob_loop2_time_start", time());
|
||||
// debuglog(__METHOD__);
|
||||
}
|
||||
|
||||
|
@ -107,11 +107,11 @@ class CronjobController extends CommonController
|
|||
|
||||
// BackendRunCoinActions();
|
||||
|
||||
$state = memcache_get($this->memcache->memcache, 'cronjob_main_state');
|
||||
$state = $this->memcache->get('cronjob_main_state');
|
||||
if(!$state) $state = 0;
|
||||
|
||||
memcache_set($this->memcache->memcache, 'cronjob_main_state', $state+1);
|
||||
memcache_set($this->memcache->memcache, "cronjob_main_state_$state", 1);
|
||||
$this->memcache->set('cronjob_main_state', $state+1);
|
||||
$this->memcache->set("cronjob_main_state_$state", 1);
|
||||
|
||||
switch($state)
|
||||
{
|
||||
|
@ -177,20 +177,20 @@ class CronjobController extends CommonController
|
|||
break;
|
||||
|
||||
default:
|
||||
memcache_set($this->memcache->memcache, 'cronjob_main_state', 0);
|
||||
$this->memcache->set('cronjob_main_state', 0);
|
||||
BackendQuickClean();
|
||||
|
||||
$t = memcache_get($this->memcache->memcache, "cronjob_main_start_time");
|
||||
$t = $this->memcache->get("cronjob_main_start_time");
|
||||
$n = time();
|
||||
|
||||
memcache_set($this->memcache->memcache, "cronjob_main_time", $n-$t);
|
||||
memcache_set($this->memcache->memcache, "cronjob_main_start_time", $n);
|
||||
$this->memcache->set("cronjob_main_time", $n-$t);
|
||||
$this->memcache->set("cronjob_main_start_time", $n);
|
||||
}
|
||||
|
||||
debuglog(__METHOD__." $state");
|
||||
memcache_set($this->memcache->memcache, "cronjob_main_state_$state", 0);
|
||||
$this->memcache->set("cronjob_main_state_$state", 0);
|
||||
|
||||
memcache_set($this->memcache->memcache, "cronjob_main_time_start", time());
|
||||
$this->memcache->set("cronjob_main_time_start", time());
|
||||
if(!YAAMP_PRODUCTION) return;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
@ -203,14 +203,14 @@ class CronjobController extends CommonController
|
|||
$mining->last_payout = time();
|
||||
$mining->save();
|
||||
|
||||
memcache_set($this->memcache->memcache, 'apache_locked', true);
|
||||
$this->memcache->set('apache_locked', true);
|
||||
if(YAAMP_USE_NGINX)
|
||||
system("service nginx stop");
|
||||
|
||||
sleep(10);
|
||||
BackendDoBackup();
|
||||
|
||||
memcache_set($this->memcache->memcache, 'apache_locked', false);
|
||||
$this->memcache->set('apache_locked', false);
|
||||
|
||||
BackendPayments();
|
||||
BackendCleanDatabase();
|
||||
|
|
Loading…
Add table
Reference in a new issue