{"id":13764074,"url":"https://github.com/abo/rerate","last_synced_at":"2025-04-27T08:31:57.478Z","repository":{"id":57497039,"uuid":"59557219","full_name":"abo/rerate","owner":"abo","description":"redis-based rate counter and rate limiter","archived":false,"fork":false,"pushed_at":"2017-03-28T02:22:25.000Z","size":45,"stargazers_count":28,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T23:11:13.715Z","etag":null,"topics":["rate-counter","rate-limiter","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-24T08:59:00.000Z","updated_at":"2024-11-19T11:51:12.000Z","dependencies_parsed_at":"2022-09-26T19:53:07.021Z","dependency_job_id":null,"html_url":"https://github.com/abo/rerate","commit_stats":null,"previous_names":["abo/ratelimiter"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abo%2Frerate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abo%2Frerate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abo%2Frerate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abo%2Frerate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abo","download_url":"https://codeload.github.com/abo/rerate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251080977,"owners_count":21533153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rate-counter","rate-limiter","redis"],"created_at":"2024-08-03T15:01:12.115Z","updated_at":"2025-04-27T08:31:56.127Z","avatar_url":"https://github.com/abo.png","language":"Go","funding_links":[],"categories":["Utilities","工具库","工具库`可以提升效率的通用代码库和工具`","實用工具","实用工具","公用事业公司","Utility"],"sub_categories":["Advanced Console UIs","HTTP Clients","查询语","高級控制台界面","高级控制台界面","实用程序/Miscellaneous","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流"],"readme":"rerate \n===========\n[![Build Status](https://travis-ci.org/abo/rerate.svg?branch=master)](https://travis-ci.org/abo/rerate)\n[![GoDoc](https://godoc.org/github.com/abo/rerate?status.svg)](https://godoc.org/github.com/abo/rerate)\n[![Go Report Card](https://goreportcard.com/badge/github.com/abo/rerate)](https://goreportcard.com/report/github.com/abo/rerate)\n[![Coverage Status](https://coveralls.io/repos/github/abo/rerate/badge.svg?branch=master)](https://coveralls.io/github/abo/rerate?branch=master)\n\nrerate is a redis-based ratecounter and ratelimiter\n\n* Dead simple api\n* With redis as backend, multiple rate counters/limiters can work as a cluster\n* Count/Limit requests any period, 2 day, 1 hour, 5 minute or 2 second, it's up to you\n* Recording requests as a histotram, which can be used to visualize or monitor\n* Limit requests from single ip, userid, applicationid, or any other unique identifier\n\n\nTutorial\n--------\n```\npackage main\n\nimport (\n    \"github.com/abo/rerate\"\n)\n\n...\n\nfunc main() {\n    // redigo buckets\n    pool := newRedisPool(\"localhost:6379\", \"\")\n    buckets := rerate.NewRedigoBuckets(pool)\n\n    // OR redis buckets\n    // client := redis.NewClient(\u0026redis.Options{\n\t//\t Addr:     \"localhost:6379\",\n\t// \t Password: \"\",\n\t// \t DB:       0,\n\t// })\n    // buckets := rerate.NewRedisBuckets(client)\n    \n    // Counter\n    counter := rerate.NewCounter(buckets, \"rl:test\", 10 * time.Minute, 15 * time.Second)\n    counter.Inc(\"click\")\n    c, err := counter.Count(\"click\")\n    \n    // Limiter\n    limiter := rerate.NewLimiter(buckets, \"rl:test\", 1 * time.Hour, 15 * time.Minute, 100)\n    limiter.Inc(\"114.255.86.200\")\n    rem, err := limiter.Remaining(\"114.255.86.200\")\n    exceed, err := limiter.Exceeded(\"114.255.86.200\")\n}\n```\n\n\nInstallation\n------------\n\nInstall rerate using the \"go get\" command:\n\n    go get github.com/abo/rerate\n\nDocumentation\n-------------\n\n- [API Reference](http://godoc.org/github.com/abo/rerate)\n- [Wiki](https://github.com/abo/rerate/wiki)\n\n\nSample - Sparkline\n------------------\n\n![](https://github.com/abo/rerate/raw/master/cmd/sparkline/sparkline.png)\n\n```\n    cd cmd/sparkline\n    npm install webpack -g\n    npm install\n    webpack \u0026\u0026 go run main.go\n```\nOpen `http://localhost:8080` in Browser, And then move mouse.\n\n\nContributing\n------------\nWELCOME\n\n\nLicense\n-------\n\nrerate is available under the [The MIT License (MIT)](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabo%2Frerate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabo%2Frerate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabo%2Frerate/lists"}