{"id":36979861,"url":"https://github.com/abtswath/limiter","last_synced_at":"2026-01-13T22:49:28.851Z","repository":{"id":239835071,"uuid":"801062575","full_name":"abtswath/limiter","owner":"abtswath","description":"API 限流器","archived":false,"fork":false,"pushed_at":"2024-05-15T14:22:24.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-16T18:05:01.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abtswath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-15T14:16:46.000Z","updated_at":"2024-05-15T14:22:28.000Z","dependencies_parsed_at":"2024-05-15T18:00:08.942Z","dependency_job_id":"05a231f2-5cbf-4502-b774-97beeb11f29a","html_url":"https://github.com/abtswath/limiter","commit_stats":null,"previous_names":["abtswath/limiter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abtswath/limiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abtswath%2Flimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abtswath%2Flimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abtswath%2Flimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abtswath%2Flimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abtswath","download_url":"https://codeload.github.com/abtswath/limiter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abtswath%2Flimiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-13T22:49:28.321Z","updated_at":"2026-01-13T22:49:28.842Z","avatar_url":"https://github.com/abtswath.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Limiter\n\nLimiter 是一个支持多种限流算法与存储后端的 API 限流器。\n\nLimiter 要求 PHP \u003e= 8.2。\n\n# 目录\n\n- [安装](#安装)\n- [代码结构](#代码结构)\n- [基本用法](#基本用法)\n    - [固定窗口算法](#固定窗口算法)\n    - [滑动日志算法](#滑动日志算法)\n\n\n## 安装\n\n```sh\ncomposer require abtswath/limiter\n```\n\n## 代码结构\n\n![UML](./docs/uml.webp)\n\n## 基本用法\n\nLimiter 支持 `PSR-4` 自动加载。\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php';\n```\n\n### 固定窗口算法\n\n```php\n\u003c?php\n\n$store = new Limiter\\Store\\MemoryStore();\n$limiter = new Limiter\\FixedWindowLimiter(store: $store, limit: 10, windowSize: 60);\n\n$limiter-\u003eattempt($key);\n```\n\n### 滑动日志算法\n\n```php\n\u003c?php\n\n$store = new Limiter\\Store\\MemoryStore();\n$limiter = new Limiter\\SlidingLogLimiter(store: $store, limit: 10, windowSize: 60);\n\n$limiter-\u003eattempt($key);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabtswath%2Flimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabtswath%2Flimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabtswath%2Flimiter/lists"}