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

ActiveLibrary[Caching](/categories/caching)

rayswoole/memcache-pool
=======================

基于swoole + easyswoole/memcache实现的memcache连接池

v1.0.0(5y ago)082Apache-2.0PHPPHP &gt;=7.1.0

Since Sep 7Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

rayswoole/memcache
==================

[](#rayswoolememcache)

基于PHP7.1+ 和 easyswoole/memcache协程连接,实现的memcache连接池：

- 直接使用TCP协议连接, 不依赖memcached扩展
- 实现了memcache的连接池, 减少频繁建立连接的开销
- 仅支持单机模式
- 支持自动保持连接
- 支持保持最小空闲连接数量, 满足突发连接
- 弹性伸缩

安装
--

[](#安装)

```
composer require rayswoole/memcache-pool

```

文档
--

[](#文档)

### 连接池配置

[](#连接池配置)

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

```

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

### redis 配置结构

[](#redis-配置结构)

```
$config = [
    'server' => '127.0.0.1',
    'port' => 11211,
];
```

### 进程池使用示例

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

```
use rayswoole\memcache\facade\Memcache;

Memcache::getInstance()->set('aa',1234);

Memcache::getInstance()->get('aa');

Memcache::getInstance()->clear();
```

### 不通过连接池直连

[](#不通过连接池直连)

```
$config = [
    'server' => '127.0.0.1',
    'port' => 11211,
];

$memcache = \rayswoole\memcache\MemcacheClient::get($config);

$memcache->set('aa',1234);
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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

2078d 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 (1 commits)")

---

Tags

memcacherayswoole

### Embed Badge

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

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

###  Alternatives

[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32135.8k](/packages/beryllium-cachebundle)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)[clickalicious/memcached.php

Memcached.php - Plain vanilla PHP Memcached client with full support of Memcached protocol.

2973.7k5](/packages/clickalicious-memcachedphp)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.1k](/packages/ihor-cachalot)

PHPackages © 2026

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