PHPackages                             rayswoole/redis-pool - 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. rayswoole/redis-pool

ActiveLibrary[Caching](/categories/caching)

rayswoole/redis-pool
====================

基于swoole + phpredis扩展的redis连接池

v1.1.3(4y ago)11281Apache-2.0PHPPHP &gt;=7.1.0

Since Aug 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/rayswoole/redis-pool)[ Packagist](https://packagist.org/packages/rayswoole/redis-pool)[ RSS](/packages/rayswoole-redis-pool/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

rayswoole/redis-pool
====================

[](#rayswooleredis-pool)

基于PHP7.1+ 和 phpredis扩展 实现的redis连接池：

- 实现了redis的连接池, 减少频繁建立连接的开销
- 支持phpredis的单机模式和Cluster模式
- 支持自动保持连接
- 支持保持最小空闲连接数量, 满足突发连接
- 弹性伸缩

安装
--

[](#安装)

```
composer require rayswoole/redis-pool

```

文档
--

[](#文档)

### 连接池配置

[](#连接池配置)

```
可以在onStart直接配置
每个worker进程都会生成同等配置的进程池, 请根据worker数量动态调整

```

```
//初始化连接配置
$redisConfig = new \rayswoole\redis\RedisConfig();
//设置最小闲置连接数
$redisConfig->withMin(20);
//设置最大连接数
$redisConfig->withMax(100);
//设置定时器执行频率(毫秒),创建最小空间连接、回收空闲连接
$redisConfig->withIntervalTime(15*1000)
//设置连接可空闲时间
$redisConfig->withIdleTime(30)
//获取连接池对象超时时间, 如果连接池占满在指定时间无法释放新的连接, 将输出Exception, 需要自行捕获
$redisConfig->withTimeout(3.0)
//数据库配置注入
$redisConfig->withExtraConf('redis配置')
//初始化连接池
\rayswoole\redis\facade\Redis::init($redisConfig);
```

### redis 配置结构

[](#redis-配置结构)

```
$config = [
    'server' => ['127.0.0.1:6379','....'],//多IP时为cluster模式
    'dbIndex' => 0,//数据库序号, 不建议变更
    'username'=>'',//适用于账号密码认证
    'password'=>'',//适用于账号密码/密码认证
    'prefix' => 'ray_',//key前缀
    'writeOnly' => false,//主服务器是否只写
    'options' => [],
];
```

### 进程池使用示例

[](#进程池使用示例)

```
use \rayswoole\redis\facade\Redis;
Redis::getInstance()->set('key', 'value');//带编辑器提示
//或者
Redis::set('key', 'value');//不带提示
```

### 不用进程池单独连接

[](#不用进程池单独连接)

```
use rayswoole\redis;
RedisClient::get($redisConfig->getExtraConf());
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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

Every ~82 days

Total

5

Last Release

1770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7fe37afe70c3655d3b66c7e6c2462056f93f58dc3a0730cafd97921044d1343?d=identicon)[haoguangyun](/maintainers/haoguangyun)

---

Top Contributors

[![rayswoole](https://avatars.githubusercontent.com/u/69523714?v=4)](https://github.com/rayswoole "rayswoole (9 commits)")[![Rhilip](https://avatars.githubusercontent.com/u/13842140?v=4)](https://github.com/Rhilip "Rhilip (1 commits)")

---

Tags

redisrayswoole

### Embed Badge

![Health badge](/badges/rayswoole-redis-pool/health.svg)

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

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[clue/redis-protocol

A streaming Redis protocol (RESP) parser and serializer written in pure PHP.

5311.0M13](/packages/clue-redis-protocol)[cache/redis-adapter

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

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

Message Queue Redis Transport

405.5M25](/packages/enqueue-redis)[kdyby/redis

Redis storage for Nette Framework

491.6M2](/packages/kdyby-redis)

PHPackages © 2026

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