We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 86a2b59 commit 24160f1Copy full SHA for 24160f1
functions/path_regex.php
@@ -26,6 +26,14 @@
26
*/
27
function path_regex(string $path) : string
28
{
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
37
$matches = path_parse($path);
38
39
foreach ($matches as $match) {
@@ -42,5 +50,7 @@ function path_regex(string $path) : string
42
50
$path = str_replace('{' . $match['name'] . '}', $subpattern, $path);
43
51
}
44
52
45
- return '#^' . $path . '$#uD';
53
+ $cache[$path] = '#^' . $path . '$#uD';
54
55
46
56
0 commit comments