Comments (4)
What version of django-ratelimit are you using? Can you include the line that's dumping out the contents of the cache, as well as the cache backend?
from django-ratelimit.
Also... because it does a > check, which ISTR is for a reason, though I'm not 100% sure what that reason was.
from django-ratelimit.
Also... because it does a > check, which ISTR is for a reason, though I'm not 100% sure what that reason was.
Ah, it's coming back to me a little—because this is an atypical way to use ratelimit.
When you use the decorator or the mixin, it pre-increments, so if you say rate='5/m'
then 5 requests per minute are allowed. When you post-increment, you're allowing the action to happen (twice) before counting it. So when you check the ratelimit in dispatch()
, you have not yet surpassed the ratelimit.
Ratelimit may not actually be the right tool here. Remember that it relies on the cache, which is not always reliable, and has staggered windows. If you only want each IP to have one submission per clock hour, just checking to see whether or not there is a saved submission since datetime.now().replace(minute=0)
might be more what you're looking to achieve.
from django-ratelimit.
Great thanks for the clarification - I thought I might be missing something - really helpful.
from django-ratelimit.
Related Issues (20)
- How can I user get_usage_count?
- ניסיון HOT 1
- [catchup] Double check CI and branch protection config HOT 1
- [catchup] Drop Python 2 support HOT 1
- [catchup] Test against modern Django HOT 1
- Automate releases
- Change default value of block kwarg
- Update package config to pyproject.toml
- `mixins.py` removed from `4.0` HOT 1
- Wrong project link on pypi HOT 4
- Unable to rate-limit on arg/kwarg value HOT 2
- Support for Django's built in `RedisCache` cache backend
- get_usage on class based view
- Expire time of Multiple ratelimit on same view not seem correct.
- Incorrect homepage link on PyPI HOT 2
- Feature request: Attach information about rate-limit violations to request object for use in custom middleware
- Blacken Codes HOT 1
- Add async support? HOT 18
- Add a configurable cache key timeout
- Add informational headers for rate-limit HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-ratelimit.