-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Documenting cache fallback #5051
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,38 @@ refer to the class name using the following syntaxes: | |
| When using the FileEngine you might need to use the ``mask`` option to | ||
| ensure cache files are made with the correct permissions. | ||
|
|
||
| .. _cache-configuration-fallback: | ||
|
|
||
| Configuring Cache Fallbacks | ||
| --------------------------- | ||
|
|
||
| In the event that an engine is not available, such as the ``FileEngine`` trying | ||
| to write to an unwritable folder or the ``RedisEngine`` failing to connect to | ||
| Redis, the engine will fall back to the noop ``NullEngine`` and trigger a loggable | ||
| error. This prevents the application from throwing an uncaught exception due to | ||
| cache failure. | ||
|
|
||
| You can configure Cache configurations to fall back to a specified config using | ||
| the ``fallback`` configuration key:: | ||
|
|
||
| Cache::config('redis', [ | ||
| 'className' => 'Redis', | ||
| 'duration' => '+1 hours', | ||
| 'prefix' => 'cake_redis_', | ||
| 'host' => '127.0.0.1', | ||
| 'port' => 6379, | ||
| 'fallback' => 'default', | ||
| ]); | ||
|
|
||
| If the Redis server unexpectedly failed, writing to the ``redis`` cache | ||
| configuration would fall back to writing to the ``default`` cache configuration. | ||
| If writing to the ``default`` cache configuration *also* failed in this scenario, the | ||
| engine would fall back once again to the ``NullEngine`` and prevent the application | ||
| from throwing an uncaught exception. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you include a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes! |
||
|
|
||
| .. versionadded:: 3.5.0 | ||
| Cache engine fallbacks were added. | ||
|
|
||
| Removing Configured Cache Engines | ||
| --------------------------------- | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious. What happens if one configures the same engine as fallback (e.g. by accident)? Do we have a clear exception for that? Something like "You are trying to configure the engine itself as its fallback"...
This would be a hard misconfiguration, something that SHOULD throw an exception, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty much exactly the exception it throws 😄 I did that exact thing while writing this haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahahaha, beautiful! 😆