Code Monkey home page Code Monkey logo

Comments (4)

jsocol avatar jsocol commented on May 14, 2024

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.

jsocol avatar jsocol commented on May 14, 2024

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.

jsocol avatar jsocol commented on May 14, 2024

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.

jvc26 avatar jvc26 commented on May 14, 2024

Great thanks for the clarification - I thought I might be missing something - really helpful.

from django-ratelimit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.