I hereby claim:
- I am rsau on github.
- I am raminder (https://keybase.io/raminder) on keybase.
- I have a public key ASCHSOrDaqZwAfQcZf3iDnMcDWXRg78GvI1v2_r4OscWlAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
" ============================================================================= | |
" Miller Medeiros .vimrc file | |
" ----------------------------------------------------------------------------- | |
" heavily inspired by: @factorylabs, @scrooloose, @nvie, @gf3, @bit-theory. | |
" ============================================================================= | |
" ----------------------------------------------------------------------------- | |
" BEHAVIOR | |
" ----------------------------------------------------------------------------- |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.