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

support multiple limits #27

Closed
willkg opened this issue Oct 29, 2013 · 1 comment
Closed

support multiple limits #27

willkg opened this issue Oct 29, 2013 · 1 comment

Comments

@willkg
Copy link
Collaborator

willkg commented Oct 29, 2013

The docs suggest to use the keys argument to support multiple limits:

@ratelimit(keys=lambda x: 'min', rate='1/m')
@ratelimit(keys=lambda x: 'hour', rate='10/h')
@ratelimit(keys=lambda x: 'day', rate='50/d')
def post(request):
    # Stack them.
    # Note: once a decorator limits the request, the ones after
    # won't count the request for limiting.
    return HttpResponse()

Without that keys argument, then all three limits use the same cache key and therefore whichever gets cleared first clears them all.

It'd be nice if stacking ratelimits worked better with cache keys.

@jsocol
Copy link
Owner

jsocol commented Sep 1, 2014

Closing in favor of #48.

@jsocol jsocol closed this as completed Sep 1, 2014
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

No branches or pull requests

2 participants