{"id":21712136,"url":"https://github.com/ofw/go-redis-ratelimiter","last_synced_at":"2025-04-12T18:03:01.660Z","repository":{"id":57504425,"uuid":"54702315","full_name":"ofw/go-redis-ratelimiter","owner":"ofw","description":"Simple thread-safe go ratelimiter library with redis backend","archived":false,"fork":false,"pushed_at":"2016-04-20T13:43:46.000Z","size":6,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T12:21:21.324Z","etag":null,"topics":[],"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/ofw.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-03-25T07:24:12.000Z","updated_at":"2023-11-03T16:07:53.000Z","dependencies_parsed_at":"2022-08-29T23:40:17.839Z","dependency_job_id":null,"html_url":"https://github.com/ofw/go-redis-ratelimiter","commit_stats":null,"previous_names":["oeegor/go-redis-ratelimiter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofw%2Fgo-redis-ratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofw%2Fgo-redis-ratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofw%2Fgo-redis-ratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofw%2Fgo-redis-ratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ofw","download_url":"https://codeload.github.com/ofw/go-redis-ratelimiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610367,"owners_count":21132920,"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":[],"created_at":"2024-11-25T23:34:30.558Z","updated_at":"2025-04-12T18:03:01.630Z","avatar_url":"https://github.com/ofw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-redis-ratelimiter\nSimple go ratelimiter library with redis backend\n\n# Docs\n\nhttps://godoc.org/github.com/oeegor/go-redis-ratelimiter\n\n# Usage\n\n```go\n\nimport (\n\t\"github.com/garyburd/redigo/redis\"\n    \"github.com/oeegor/go-redis-ratelimiter\"\n)\n\nfunc main() {\n\n    // initialize redis pool\n    redisPool := redis.NewPool(func() (redis.Conn, error) {\n\t\tc, err := redis.Dial(\"tcp\", \"your-redis-address\")\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn c, err\n\t}, 100)  // also set max connections to 100\n\n    // increment rate limit usage for given key that is allowed 10 requests per second with one try\n    // Ratelimiter will try to acquire limit N tries using time.Sleep between tries\n    limitCtx, err := ratelimiter.Incr(redisPool, \"mykey\", 10, time.Second, 1)\n\n    if err != nil {\n        // do something\n    }\n\n    // limitCtx contains all necessary data for ratelimiter state\n    if limitCtx.Reached() {\n        // code to handle over the limit logic\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofw%2Fgo-redis-ratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofw%2Fgo-redis-ratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofw%2Fgo-redis-ratelimiter/lists"}