Skip to content

Commit 1ce41a1

Browse files
committed
some update
1 parent b376fb0 commit 1ce41a1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/AbstractRouter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ abstract class AbstractRouter implements RouterInterface
105105
/**
106106
* regular Routes - have dynamic arguments, but the first node is normal string.
107107
* 第一节是个静态字符串,称之为有规律的动态路由。按第一节的信息进行分组存储
108-
* e.g '/hello[/{name}]' '/user/{id}'
108+
* e.g '/hello/{name}' '/user/{id}'
109109
* @var array[]
110110
* [
111111
* // 使用完整的第一节作为key进行分组
@@ -321,7 +321,7 @@ public static function validateArguments($methods, $handler)
321321
* @param string $route
322322
* @return bool
323323
*/
324-
protected static function isStaticRoute($route)
324+
public static function isStaticRoute($route)
325325
{
326326
return strpos($route, '{') === false && strpos($route, '[') === false;
327327
}

src/ORouter.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,13 @@ protected function cacheMatchedParamRoute($path, $method, array $conf)
405405
$cacheNumber = (int)$this->config['tmpCacheNumber'];
406406

407407
// cache last $cacheNumber routes.
408-
if ($cacheNumber > 0) {
409-
if ($this->cacheCounter === $cacheNumber) {
408+
if ($cacheNumber > 0 && !isset($this->routeCaches[$path][$method])) {
409+
if ($this->cacheCounter >= $cacheNumber) {
410410
array_shift($this->routeCaches);
411411
}
412412

413-
if (!isset($this->routeCaches[$path][$method])) {
414-
$this->cacheCounter++;
415-
$this->routeCaches[$path][$method] = $conf;
416-
}
413+
$this->cacheCounter++;
414+
$this->routeCaches[$path][$method] = $conf;
417415
}
418416
}
419417

0 commit comments

Comments
 (0)