File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 6363 */
6464function 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 ])) {
Original file line number Diff line number Diff line change 2626 */
2727function 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}
You can’t perform that action at this time.
0 commit comments