PHPackages                             v10086/redis-ratelimit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. v10086/redis-ratelimit

ActiveLibrary[Caching](/categories/caching)

v10086/redis-ratelimit
======================

基于redis的限流器

v1.0(3y ago)0441Apache-2.0PHPPHP &gt;=7.0

Since Mar 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/v10086/redis-ratelimit)[ Packagist](https://packagist.org/packages/v10086/redis-ratelimit)[ RSS](/packages/v10086-redis-ratelimit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

📃 开源协议 Apache License Version 2.0 see

简介
==

[](#简介)

基于redis实现的的限流器

版本说明
----

[](#版本说明)

PHP7.0+版本 必须安装phpredis拓展

安装教程
----

[](#安装教程)

composer require v10086/redis-ratelimit:v1.0

使用示例
----

[](#使用示例)

```
namespace v10086;
//访问频率限制  使用示例:
// \library\RedisRateLimit::$redisHandler=已完成连接接的redis C 端;
// \v10086\RedisRateLimit::check('api',[5=>2,10=>5]);
// 表示某个api 5秒内最多访问2次 ,10秒内最多访问5次
class RedisRateLimit {

    public static $redisHandler=null; //redis操作句柄 默认为空
    public static $msg='ok';

    public static function check($limitKey,$policy){

        $rateKeyPrefix='rateLimit:'.$limitKey.':';
        foreach ($policy as $policyKey=>$policyVal) {
            $rateKey=$rateKeyPrefix.$policyKey;
            $count= self::$redisHandler->INCR($rateKey,1);
            if($count==1){
               self::$redisHandler->EXPIRE($rateKey,$policyKey);
            }
            if ($count>$policyVal) {
                self::$msg=[$policyKey=>$policyVal];
                return false;
            }
        }
        return  true;
    }
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1159d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ca792228b0e2635c7cde8124689ecd7e5cc5ecdae1586f74a3ddaaeafd8b4d7?d=identicon)[v10086](/maintainers/v10086)

---

Top Contributors

[![v10086](https://avatars.githubusercontent.com/u/15503470?v=4)](https://github.com/v10086 "v10086 (4 commits)")

---

Tags

php-libraryredisredlock-redisphpredisphpredisratelimit

### Embed Badge

![Health badge](/badges/v10086-redis-ratelimit/health.svg)

```
[![Health](https://phpackages.com/badges/v10086-redis-ratelimit/health.svg)](https://phpackages.com/packages/v10086-redis-ratelimit)
```

###  Alternatives

[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)[swoft/redis

swoft redis component

12168.4k16](/packages/swoft-redis)[perimeter/rate-limiter-php

A very simple Rate Limiter for PHP

1715.4k1](/packages/perimeter-rate-limiter-php)[eftec/cacheone

A Cache library with minimum dependency

103.5k4](/packages/eftec-cacheone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
