Skip to content

Add Reset function to remove history of a key #43

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

Merged
merged 2 commits into from
Nov 19, 2020
Merged

Conversation

sashati
Copy link
Contributor

@sashati sashati commented Nov 19, 2020

Here I just added a new Lua script that removes the corresponding key from Redis to reset its functionality.

rate.go Outdated
@@ -158,6 +158,15 @@ func (l Limiter) AllowAtMost(
return res, nil
}

// Reset gets a key and reset all limitations and previous usages
func (l *Limiter) Reset(ctx context.Context, key string) error {
_, err := reset.Run(ctx, l.rdb, []string{redisPrefix + key}, nil).Result()
Copy link
Member

Choose a reason for hiding this comment

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

Please remove Lua script and just call l.rdb.Del(ctx, redisPrefix + key)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment. I just removed the script and used the Del function instead.

@vmihailenco
Copy link
Member

Thanks!

@vmihailenco vmihailenco merged commit 326ae61 into go-redis:v9 Nov 19, 2020
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.

2 participants