Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure caching config is compatible with v1 #272

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $r->addRoute('POST', '/test', 'handler');
$r->addRoute(['GET', 'POST'], '/test', 'handler');
```

By default the `$routePattern` uses a syntax where `{foo}` specifies a placeholder with name `foo`
By default, the `$routePattern` uses a syntax where `{foo}` specifies a placeholder with name `foo`
and matching the regex `[^/]+`. To adjust the pattern the placeholder matches, you can specify
a custom pattern by writing `{bar:[0-9]+}`. Some examples:

Expand Down Expand Up @@ -142,7 +142,7 @@ $r->addRoute('POST', '/post-route', 'post_handler');

#### Route Groups

Additionally, you can specify routes inside of a group. All routes defined inside a group will have a common prefix.
Additionally, you can specify routes inside a group. All routes defined inside a group will have a common prefix.

For example, defining your routes as:

Expand Down Expand Up @@ -178,13 +178,15 @@ $dispatcher = FastRoute\cachedDispatcher(function(FastRoute\RouteCollector $r) {
$r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1');
$r->addRoute('GET', '/user/{name}', 'handler2');
}, [
'cacheFile' => __DIR__ . '/route.cache', /* required */
'cacheKey' => __DIR__ . '/route.cache', /* required */
// 'cacheFile' => __DIR__ . '/route.cache', /* will still work for v1 compatibility */
'cacheDisabled' => IS_DEBUG_ENABLED, /* optional, enabled by default */
'cacheDriver' => FastRoute\Cache\FileCache::class, /* optional, class name or instance of the cache driver - defaults to file cache */
]);
```

The second parameter to the function is an options array, which can be used to specify the cache
file location, among other things.
key (e.g. file location when using files for caching), caching driver, among other things.

### Dispatching a URI

Expand Down
Loading
Loading