Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #4 from justonia/fix-expiry
Browse files Browse the repository at this point in the history
Fix issue #3 where key expiry is incorrectly propagated to keys without expiry
  • Loading branch information
titanous committed Dec 7, 2015
2 parents 3454dca + 0c276fd commit f5614b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (d *decode) decode() error {
if err != nil {
return err
}
expiry = 0
}
}

Expand Down
9 changes: 9 additions & 0 deletions decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ func (s *DecoderSuite) TestExpiry(c *C) {
c.Assert(r.expiries[0]["expires_ms_precision"], Equals, int64(1671963072573))
}

func (s *DecoderSuite) TestMixedExpiry(c *C) {
r := decodeRDB("keys_with_mixed_expiry")
c.Assert(r.expiries[0]["key01"], Not(Equals), int64(0))
c.Assert(r.expiries[0]["key04"], Not(Equals), int64(0))

c.Assert(r.expiries[0]["key02"], Equals, int64(0))
c.Assert(r.expiries[0]["key03"], Equals, int64(0))
}

func (s *DecoderSuite) TestIntegerKeys(c *C) {
r := decodeRDB("integer_keys")
c.Assert(r.dbs[0]["125"], Equals, "Positive 8 bit integer")
Expand Down
Binary file added fixtures/keys_with_mixed_expiry.rdb
Binary file not shown.

0 comments on commit f5614b4

Please sign in to comment.