Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Get, reuse counter value returned by incr operation #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ankitd009
Copy link

@ankitd009 ankitd009 commented Aug 11, 2019

Avoid making an extra Get call to read counter's value, use the incremented value returned by INCR operation.

Testing Strategy: existing tests for rate limit should pass.

c.Send("MULTI")
c.Send("INCR", "foo")
c.Send("EXPIRE", "foo", 300)
r, err := c.Do("EXEC")
// prints [1, 1]
// r[0] result of incr operation
// r[1 ] result of expire, 1 if the timeout was set, 0 if key does not exist.
fmt.Println(r) 

Redis-Expire Doc
Redigo-Pipeline Doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant