Finds profiler tokens for the given criteria.
string $ip The IP:
string $url The URL:
string $limit The maximum number of tokens to return:
string $method The request method:
array An array of tokens
Overrides ProfilerStorageInterface::find
public function find($ip, $url, $limit, $method) {
$indexName = $this
->getIndexName();
if (!($indexContent = $this
->getValue($indexName, self::REDIS_SERIALIZER_NONE))) {
return array();
}
$profileList = explode("\n", $indexContent);
$result = array();
foreach ($profileList as $item) {
if ($limit === 0) {
break;
}
if ($item == '') {
continue;
}
list($itemToken, $itemIp, $itemMethod, $itemUrl, $itemTime, $itemParent) = explode("\t", $item, 6);
if ($ip && false === strpos($itemIp, $ip) || $url && false === strpos($itemUrl, $url) || $method && false === strpos($itemMethod, $method)) {
continue;
}
$result[$itemToken] = array(
'token' => $itemToken,
'ip' => $itemIp,
'method' => $itemMethod,
'url' => $itemUrl,
'time' => $itemTime,
'parent' => $itemParent,
);
--$limit;
}
usort($result, function ($a, $b) {
if ($a['time'] === $b['time']) {
return 0;
}
return $a['time'] > $b['time'] ? -1 : 1;
});
return $result;
}