mirror of
https://github.com/YGGverse/YGGstate.git
synced 2025-01-09 22:37:54 +00:00
reduce server load by caching past results in the active month for 30 days
This commit is contained in:
parent
c1dc5030e6
commit
0e748f97df
@ -50,11 +50,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime('+1 day', strtotime(sprintf('%s-%s-%s 00:00', date('Y', $requestTime), date('n', $requestTime), $day)));
|
||||
|
||||
$dbPeerTotalByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerTotalByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerTotalByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerTotalByTimeAdded = $memory->getByMethodCallback(
|
||||
$db, 'findPeerTotalByTimeAdded', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerTotalByTimeAdded', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
// Add daily stats
|
||||
@ -68,11 +68,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime(sprintf('%s-%s-%s %s:00', date('Y', $requestTime), date('n', $requestTime), $day, $hour + 1));
|
||||
|
||||
$dbPeerTotalByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerTotalByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerTotalByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerTotalByTimeAdded = $memory->getByMethodCallback(
|
||||
$db, 'findPeerTotalByTimeAdded', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerTotalByTimeAdded', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$calendar->addNode($day, $dbPeerTotalByTimeUpdated, sprintf(_('%s:00-%s:00 online %s'), $hour, $hour + 1, $dbPeerTotalByTimeUpdated), 'green', 1);
|
||||
@ -87,11 +87,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime('+1 day', strtotime(sprintf('%s-%s-%s 00:00', date('Y', $requestTime), date('n', $requestTime), $day)));
|
||||
|
||||
$dbPeerSessionSentSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerSessionReceivedSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
// Add daily stats
|
||||
@ -105,11 +105,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime(sprintf('%s-%s-%s %s:00', date('Y', $requestTime), date('n', $requestTime), $day, $hour + 1));
|
||||
|
||||
$dbPeerSessionSentSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerSessionReceivedSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo]
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$calendar->addNode($day, $dbPeerSessionSentSumByTimeUpdated, sprintf(_('%s:00-%s:00 ↑ %s'), $hour, $hour + 1, number_format($dbPeerSessionSentSumByTimeUpdated / 1000000, 3)), 'red', 1);
|
||||
|
@ -52,11 +52,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime('+1 day', strtotime(sprintf('%s-%s-%s 00:00', date('Y', $requestTime), date('n', $requestTime), $day)));
|
||||
|
||||
$dbPeerSessionSentSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId]
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerSessionReceivedSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId]
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
// Add daily stats
|
||||
@ -70,11 +70,11 @@ foreach ($calendar->getNodes() as $day => $node) {
|
||||
$timeTo = strtotime(sprintf('%s-%s-%s %s:00', date('Y', $requestTime), date('n', $requestTime), $day, $hour + 1));
|
||||
|
||||
$dbPeerSessionSentSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId]
|
||||
$db, 'findPeerSessionSentSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$dbPeerSessionReceivedSumByTimeUpdated = $memory->getByMethodCallback(
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId]
|
||||
$db, 'findPeerSessionReceivedSumByTimeUpdated', [$timeFrom, $timeTo, $requestPeerId], ($timeTo <= $requestTime ? 2592000 : MEMCACHED_TIMEOUT) + time()
|
||||
);
|
||||
|
||||
$calendar->addNode($day, $dbPeerSessionSentSumByTimeUpdated, sprintf(_('%s:00-%s:00 ↑ %s'), $hour, $hour + 1, number_format($dbPeerSessionSentSumByTimeUpdated / 1000000, 3)), 'red', 1);
|
||||
|
Loading…
Reference in New Issue
Block a user