PHPackages                             imiphp/imi-shared-memory - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. imiphp/imi-shared-memory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

imiphp/imi-shared-memory
========================

imi 框架跨进程变量共享组件

v2.1.8(1y ago)7192MulanPSL-2.0PHP

Since Dec 19Pushed 1y ago2 watchersCompare

[ Source](https://github.com/imiphp/imi-shared-memory)[ Packagist](https://packagist.org/packages/imiphp/imi-shared-memory)[ RSS](/packages/imiphp-imi-shared-memory/feed)WikiDiscussions 2.0 Synced 2d ago

READMEChangelog (6)Dependencies (2)Versions (23)Used By (0)

imi-shared-memory
=================

[](#imi-shared-memory)

[![Latest Version](https://camo.githubusercontent.com/b83910ec309fa1592686f63e976e3442ae2a8b03d5545842e90f55c43770b347/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d697068702f696d692d7368617265642d6d656d6f72792e737667)](https://packagist.org/packages/imiphp/imi-shared-memory)[![Php Version](https://camo.githubusercontent.com/4a5c2ab20974058a8bab53ecb30ac4c2e6bb961df6229b7386fdc097ab53dfa8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e342d627269676874677265656e2e737667)](https://secure.php.net/)[![Swoole Version](https://camo.githubusercontent.com/f077644cadc3b88104d75a54818d0e1462f910dc6d6dfd9939ea295fb11b4e2b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d2533453d342e312e302d627269676874677265656e2e737667)](https://github.com/swoole/swoole-src)[![IMI License](https://camo.githubusercontent.com/d345e882bcf256f33a25995ce51d7e35120e115ca51a6da698c678b598e32c50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696d697068702f696d692d7368617265642d6d656d6f72792e737667)](https://github.com/imiphp/imi-shared-memory/blob/master/LICENSE)

介绍
--

[](#介绍)

基于 [Swoole Shared Memory](https://github.com/Yurunsoft/swoole-shared-memory) 开发的 `imi` 框架跨进程变量共享组件。

> 本仓库仅用于浏览，不接受 issue 和 Pull Requests，请前往：

Composer
--------

[](#composer)

本项目可以使用composer安装，遵循psr-4自动加载规则，在你的 `composer.json` 中加入下面的内容:

```
{
    "require": {
        "imiphp/imi-shared-memory": "~2.0.0"
    }
}
```

然后执行 `composer update` 安装。

使用
--

[](#使用)

在项目 `config/config.php` 中配置：

```
[
    'components'    =>  [
        // 引入本组件
        'SharedMemory'    =>  'Imi\SharedMemory',
    ],
    'pools'    =>    [
        // 客户端连接池
        'sharedMemory'  =>  [
            'async' =>  [
                'pool'    =>    [
                    'class'        =>    \Imi\SharedMemory\Pool\ClientPool::class,
                    'config'    =>    [
                        'maxResources'    =>    100,
                        'minResources'    =>    0,
                    ],
                ],
                'resource'  =>  [
                    // 以下为可选配置

                    // 存储器类型，注意和下面的类名不同
                    // 'storeTypes'    =>  [
                    //     \Yurun\Swoole\SharedMemory\Client\Store\KV::class,
                    //     \Yurun\Swoole\SharedMemory\Client\Store\Stack::class,
                    //     \Yurun\Swoole\SharedMemory\Client\Store\Queue::class,
                    //     \Yurun\Swoole\SharedMemory\Client\Store\PriorityQueue::class,
                    //      'name'  =>  'XXXClass',
                    // ],

                    // unix socket 文件名，默认会自动放 runtime 目录中
                    // 'socketFile'    =>  '',
                ],
            ],
        ]
    ],
    // 以下为可选配置
    // 'swooleSharedMemory'    =>  [
        // unix socket 文件名，默认会自动放 runtime 目录中
        // 'socketFile'    =>  '',

        // 存储器类型，注意和上面的类名不同
        // 'storeTypes'    =>  [
        //     \Yurun\Swoole\SharedMemory\Store\KV::class,
        //     \Yurun\Swoole\SharedMemory\Store\Stack::class,
        //     \Yurun\Swoole\SharedMemory\Store\Queue::class,
        //     \Yurun\Swoole\SharedMemory\Store\PriorityQueue::class,
        //      'name'  =>  'XXXClass',
        // ],

        // 默认连接池名
        // 'defaultPool'   =>  'sharedMemory'
    // ],
]
```

在代码中操作：

```
// 方法一
SharedMemory::use('KV', function(\Yurun\Swoole\SharedMemory\Client\Store\KV $kv){
    $kv->set('a', 1);
});

// 方法二
$kv = SharedMemory::getInstance()->getObject('KV');
$kv->set('a', 1);
```

免费技术支持
------

[](#免费技术支持)

QQ群：17916227 [![点击加群](https://camo.githubusercontent.com/75b53e353bb9e5064662e185a6d39f4bb88c4e45bd3a1240ddf599525edb6afa/68747470733a2f2f7075622e69647171696d672e636f6d2f7770612f696d616765732f67726f75702e706e67 "点击加群")](https://jq.qq.com/?_wv=1027&k=5wXf4Zq)，如有问题会有人解答和修复。

运行环境
----

[](#运行环境)

- [PHP](https://php.net/) &gt;= 7.4
- [Composer](https://getcomposer.org/) &gt;= 2.0
- [Swoole](https://www.swoole.com/) &gt;= 4.1.0

版权信息
----

[](#版权信息)

`imi-shared-memory` 遵循 MIT 开源协议发布，并提供免费使用。

捐赠
--

[](#捐赠)

[![](https://raw.githubusercontent.com/imiphp/imi/2.0/res/pay.png)](https://raw.githubusercontent.com/imiphp/imi/2.0/res/pay.png)

开源不求盈利，多少都是心意，生活不易，随缘随缘……

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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

Every ~92 days

Total

23

Last Release

665d ago

Major Versions

1.x-dev → v2.0.02021-08-20

v2.0.7 → 3.0.x-dev2023-12-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/imiphp-imi-shared-memory/health.svg)

```
[![Health](https://phpackages.com/badges/imiphp-imi-shared-memory/health.svg)](https://phpackages.com/packages/imiphp-imi-shared-memory)
```

###  Alternatives

[robole/sulu-ai-translator-bundle

Translate any type of content using DeepL

181.3k](/packages/robole-sulu-ai-translator-bundle)

PHPackages © 2026

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