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

Return cached on error when dropOnError is false #109

Merged
merged 2 commits into from Nov 19, 2014

Conversation

@nathanmesserbbc
Copy link
Contributor

nathanmesserbbc commented Oct 27, 2014

No description provided.

@nathanmesserbbc

This comment has been minimized.

Copy link
Contributor Author

nathanmesserbbc commented Oct 28, 2014

The previous pull request: #98 prevented a stale value being dropped from the cache if there was an error or a timeout from the generate function, however on timeout the calling client would get the stale value, but on error it would get the cached value.

This PR adds, if dropOnError is set to false, returning the stale value from get. It also returns the error that was received.

I wasn't sure if this would be preferred, so clients know there was an error, but have the stale value, or if returning no error would be preferable. For our use case getting a stale value but knowing there was an error is useful.

@jardakotesovec

This comment has been minimized.

Copy link
Contributor

jardakotesovec commented Oct 29, 2014

dropOnError option is not documented

@nathanmesserbbc

This comment has been minimized.

Copy link
Contributor Author

nathanmesserbbc commented Oct 31, 2014

I've added some documentation.

The original issue discussing this option was #97

Is the behaviour here, returning the stale value and the error if the value is being retained (before the error and no value was being returned) seem reasonable?

It suits our use case, as we get stale on error behaviour, but we also get notified that there was an error and can monitor and report on this.

@hueniverse hueniverse added the feature label Nov 19, 2014
@hueniverse hueniverse added this to the 4.2.0 milestone Nov 19, 2014
@hueniverse hueniverse self-assigned this Nov 19, 2014
hueniverse added a commit that referenced this pull request Nov 19, 2014
Adding stale on error in addition to stale on timeout
@hueniverse hueniverse merged commit 710117e into hapijs:master Nov 19, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@hueniverse hueniverse changed the title Adding stale on error in addition to stale on timeout Return cached on error when dropOnError is false Nov 19, 2014
hueniverse added a commit that referenced this pull request Nov 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.