Skip to content

Commit

Permalink
feat(cache): cleanup cache entry if stale
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebachelier committed Feb 19, 2016
1 parent 628e89b commit 8129677
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ function cache (config = {}) {

return store.getItem(uuid).then(value => {
return config.readCache(req, config.log)(value)
.catch(err => { // eslint-disable-line handle-callback-err
f()
.catch(err => {
// clean up cache if stale
err.reason === 'cache-stale' ? store.removeItem(uuid).then(f) : f()
})
})
}
Expand Down

0 comments on commit 8129677

Please sign in to comment.