Merge pull request #2003 from nextcloud/query-logger-limit
Cap the number of queries we save in the query logger
This commit is contained in:
commit
9e27e2f048
|
@ -77,6 +77,10 @@ class CappedMemoryCache implements ICache, \ArrayAccess {
|
|||
$this->remove($offset);
|
||||
}
|
||||
|
||||
public function getData() {
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
|
||||
private function garbageCollect() {
|
||||
while (count($this->cache) > $this->capacity) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace OC\Diagnostics;
|
||||
|
||||
use OC\Cache\CappedMemoryCache;
|
||||
use OCP\Diagnostics\IQueryLogger;
|
||||
|
||||
class QueryLogger implements IQueryLogger {
|
||||
|
@ -34,7 +35,15 @@ class QueryLogger implements IQueryLogger {
|
|||
/**
|
||||
* @var \OC\Diagnostics\Query[]
|
||||
*/
|
||||
protected $queries = array();
|
||||
protected $queries;
|
||||
|
||||
/**
|
||||
* QueryLogger constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->queries = new CappedMemoryCache(1024);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sql
|
||||
|
@ -65,6 +74,6 @@ class QueryLogger implements IQueryLogger {
|
|||
* @return Query[]
|
||||
*/
|
||||
public function getQueries() {
|
||||
return $this->queries;
|
||||
return $this->queries->getData();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue