ratelimit
Version, currently master branch1 version
- master branchlatestOct 31, 2015
github.com/ukd1/crystal-ratelimit
A rate limiting class for Crystal
7 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
ratelimit:
github: ukd1/crystal-ratelimit
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- Russell Smith <russ@rainforestqa.com>
Dependencies
Runtime Dependencies
- redis~> 1.2.0github: stefanwille/crystal-redis
README
# ratelimit
[](https://travis-ci.org/ukd1/crystal-ratelimit)
Simple rate limiting class, backed by Redis sorted sets that use a minimal amounts of keys.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
ratelimit:
github: ukd1/ratelimit
```
## Usage
```crystal
require "redis"
require "ratelimit"
redis = Redis.new()
# make a new rate limit instace, passing in a redis connection
r = Ratelimit.new(redis)
# limit request over this interval, in milliseconds
interval = 100
# allow max of this many requests in the interval
limit = 10
# loop until we go over the limit
until r.over_limit?("test", limit, interval)
puts "Doing request"
r.add("test", interval)
end
puts "Hit limit : #{r.used("test")}"
```
## Development
You'll need a working Redis database.
## Contributing
1. Fork it ( https://github.com/[your-github-name]/ratelimit/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [[ukd1]](https://github.com/ukd1) Russell Smith - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Oct 31, 2015
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/ukd1/crystal-ratelimit
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 1