[Fix][CachedRouting] Persist route cache in local file store - #27
Merged
Conversation
Route caching resolved the container's default cache store, which in production is Redis. Because routes are loaded during application boot (`start.php` -> `routes.php` -> `Route::cache()`), every web request and artisan command — including `queue:work` — issued a Redis GET at boot. When Redis was unreachable the whole boot failed with `Predis\Connection\ConnectionException`. Route cache is a build-time artifact that is deterministic per release, so it belongs on local disk, mirroring modern Laravel's file-based route cache. Pin the store to the "file" driver so booting never depends on a networked cache. Invalidation is unchanged (cache key already embeds the route file mtime). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CachedRouting\Router::cache()/clearCache()resolved the container's default cache store — which in production is Redis. Routes are loaded during application boot (Foundation/start.php→app/routes.php→Route::cache()), so every web request and artisan command — includingqueue:work— issued a RedisGETat boot. When Redis was unreachable, boot itself failed:Route cache is a build-time artifact, deterministic per release — it belongs on local disk, exactly like modern Laravel's file-based route cache (
bootstrap/cache/routes-v7.php, loaded viarequire, never a network store).What it changes
Router::cache()/clearCache()now use thefilecache driver via a smallgetRouteCacher()helper, instead of the default (Redis) store. Booting no longer depends on a networked cache.filemtime, so a new deploy auto-rebuilds on first hit.No public API change;
Route::cache(__FILE__, ...)call sites are untouched.