Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Return cached on error when dropOnError is false #109
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.
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.