Skip to content

Commit

Permalink
Merge pull request #45 from andrewhoff/master
Browse files Browse the repository at this point in the history
Handle both redis response codes on PTTL
  • Loading branch information
novln authored Nov 7, 2018
2 parents cfd0e75 + c17dbb0 commit 3cab803
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/store/redis/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@ func updateValue(rtx *libredis.Tx, key string, expiration time.Duration) (int64,
return 0, 0, err
}

// If ttl is negative, we have to define key expiration.
if ttl < 0 {
// If ttl is -1, we have to define key expiration.
// PTTL return values changed as of Redis 2.8
// Now the command returns -2 if the key does not exist, and -1 if the key exists, but there is no expiry set
// We shouldn't try to set an expiry on a key that doesn't exist
if ttl == -1 {
expire := rtx.Expire(key, expiration)

ok, err := expire.Result()
Expand Down

0 comments on commit 3cab803

Please sign in to comment.