[IMPROVED] Cache active workers
This commit is contained in:
parent
98259e786c
commit
1f491497bc
@ -199,13 +199,14 @@ class Worker extends Base {
|
|||||||
**/
|
**/
|
||||||
public function getCountAllActiveWorkers() {
|
public function getCountAllActiveWorkers() {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
|
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT COUNT(DISTINCT(username)) AS total
|
SELECT COUNT(DISTINCT(username)) AS total
|
||||||
FROM " . $this->share->getTableName() . "
|
FROM " . $this->share->getTableName() . "
|
||||||
WHERE our_result = 'Y'
|
WHERE our_result = 'Y'
|
||||||
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
||||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||||
return $result->fetch_object()->total;
|
return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->total);
|
||||||
return $this->sqlError();
|
return $this->sqlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user