Skip to content

Commit 43f5a92

Browse files
authored
Merge pull request #96 from sunrise-php/release/v2.14.1
v2.14.1
2 parents afc5114 + 24160f1 commit 43f5a92

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

functions/path_parse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
*/
6464
function path_parse(string $path) : array
6565
{
66+
// This will be useful for a long-running application,
67+
// for example if you use the RoadRunner server...
6668
static $cache = [];
6769

6870
if (isset($cache[$path])) {

functions/path_regex.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
*/
2727
function path_regex(string $path) : string
2828
{
29+
// This will be useful for a long-running application,
30+
// for example if you use the RoadRunner server...
31+
static $cache = [];
32+
33+
if (isset($cache[$path])) {
34+
return $cache[$path];
35+
}
36+
2937
$matches = path_parse($path);
3038

3139
foreach ($matches as $match) {
@@ -42,5 +50,7 @@ function path_regex(string $path) : string
4250
$path = str_replace('{' . $match['name'] . '}', $subpattern, $path);
4351
}
4452

45-
return '#^' . $path . '$#uD';
53+
$cache[$path] = '#^' . $path . '$#uD';
54+
55+
return $cache[$path];
4656
}

0 commit comments

Comments
 (0)