[UPDATE] Cache transaction summaries
This commit is contained in:
parent
78ae3174d8
commit
f80826ff71
@ -52,9 +52,10 @@ class Transaction extends Base {
|
|||||||
* @return data array type and total
|
* @return data array type and total
|
||||||
**/
|
**/
|
||||||
public function getTransactionSummary($account_id=NULL) {
|
public function getTransactionSummary($account_id=NULL) {
|
||||||
|
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT
|
SELECT
|
||||||
SUM(t.amount) AS total, t.type AS type
|
SUM(t.amount) AS total, t.type AS type
|
||||||
FROM transactions AS t
|
FROM transactions AS t
|
||||||
LEFT OUTER JOIN blocks AS b
|
LEFT OUTER JOIN blocks AS b
|
||||||
ON b.id = t.block_id
|
ON b.id = t.block_id
|
||||||
@ -79,7 +80,8 @@ class Transaction extends Base {
|
|||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
$aData[$row['type']] = $row['total'];
|
$aData[$row['type']] = $row['total'];
|
||||||
}
|
}
|
||||||
return $aData;
|
// Cache data for a while, query takes long on many rows
|
||||||
|
return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData, 60);
|
||||||
}
|
}
|
||||||
return $this->sqlError();
|
return $this->sqlError();
|
||||||
}
|
}
|
||||||
@ -277,6 +279,7 @@ class Transaction extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$transaction = new Transaction();
|
$transaction = new Transaction();
|
||||||
|
$transaction->setMemcache($memcache);
|
||||||
$transaction->setDebug($debug);
|
$transaction->setDebug($debug);
|
||||||
$transaction->setMysql($mysqli);
|
$transaction->setMysql($mysqli);
|
||||||
$transaction->setConfig($config);
|
$transaction->setConfig($config);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user