lajouizakariae/rate-limiter
最新稳定版本:0.0.2
Composer 安装命令:
composer require lajouizakariae/rate-limiter
包简介
Rate limiter built with Php
README 文档
README
Introduction
This package is a rate limiter that allows you to define a limit per (minute,hour, or any number of seconds) It Provides different methods that allow you to define, delete, increment the rate.
Installation
composer require lajouizakariae/rate-limiter
Basic Usage
use RateLimiter\RateLimiter; $rateLimiter = new RateLimiter([ 'storage' => "file", 'path' => "storage/cache", ]); $rateLimiter->limitHourly('user:one', 3); if ($rateLimiter->tooManyAttempts('user:one')) { # Do Something } $rateLimiter->hit('user:one');
Create a Rate Limiter
You can create a rate limiter by instanciating the RateLimiter class, the only required parameter is an associative array.
You need to define wich type of storage you will be using, currently this package only supports the file system storage.
If you choose to save the rate limiter's data in the file system you need to provide a path key that shows the rate limiter where to store the data.
If the directory does not exist it will create it for you.
Note: The path should be an absolute path to the directory where you want the data to be saved.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-03-18