Skip to content

Commit

Permalink
Revert "(get) return undefined when key is expired"
Browse files Browse the repository at this point in the history
This reverts commit dcb3a19.
This fixes #154.
  • Loading branch information
erdii committed Nov 16, 2019
1 parent 21a8dc0 commit 6eaa26e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _src/lib/node_cache.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ module.exports = class NodeCache extends EventEmitter
# data is invalid if the ttl is too old and is not 0
# console.log data.t < Date.now(), data.t, Date.now()
if data.t isnt 0 and data.t < Date.now()
_retval = false
if @options.deleteOnExpire
_retval = false
@del( key )
@emit( "expired", key, @_unwrap(data) )

Expand Down
4 changes: 2 additions & 2 deletions _src/test/mocha_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1014,11 +1014,11 @@ describe "`#{pkg.name}@#{pkg.version}` on `node@#{process.version}`", () ->
return


it "set a key key with a cache initialized with no automatic delete on expire should be undefined", (done) ->
it "set a key key with a cache initialized with no automatic delete on expire", (done) ->
localCacheNoDelete.set state.key1, state.val
setTimeout(() ->
res = localCacheNoDelete.get state.key1
should(res).eql(undefined)
should(res).eql(state.val)
done()
return
, 500)
Expand Down

0 comments on commit 6eaa26e

Please sign in to comment.