Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ratelimit/ratelimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ var grant = func(
return false, 0, errors.Wrap(err, "transaction failed")
}

_, err = conn.Do("EXPIRE", key, 60*60*24*30)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try adding this before the EXEC above? Then it's run in the same transaction, which should be slightly better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arp242 hey martin - good to see hear from you. No i purposely put this out the transaction block to ensure the ttl is only applied in case the transaction is successful. Wouldn't want to ttl the list if something went weird in the multi above. You could argue that the ttl applies in any case, i'll let @ripexz decide

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk, just wasn't clear if you did it on purpose or if you just didn't notice. I don't really have an opinion other than that, although the transaction should be atomic(?)

Haven't seen you around since I got in Cork btw! Drop me a line at martin@arp242.net and we'll set up a date next week 😚 (I'll be leaving again after that)

if err != nil {
return false, 0, errors.Wrap(err, "failed to set TTL on zlist")
}

keys, err := redis.Strings(results[len(results)-1], err)
if err != nil {
return false, 0, errors.Wrap(err, "failed to parse results")
Expand Down