PHPackages                             yangyao/shm-cache - 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. yangyao/shm-cache

ActiveLibrary[Caching](/categories/caching)

yangyao/shm-cache
=================

yet another php shm cache

3171PHP

Since Apr 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yangyao/shm-cache)[ Packagist](https://packagist.org/packages/yangyao/shm-cache)[ RSS](/packages/yangyao-shm-cache/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

shm-cache
=========

[](#shm-cache)

yet another php cache based on share memory

how to use ?
------------

[](#how-to-use-)

install var composer

```
composer require yangyao/shm-cache
```

basic use .

```
$shm = new Yangyao\ShmCache\ShmHashMap();
$shm->create(0x2222);
$shm->set('hello','world');
$shm->get('hello');
```

master and salver

```
$masterKey = 0x2222;
$salverKey = 0x2223;
$key = 'hello';
// add key to master
$shmMaster = new Yangyao\ShmCache\ShmHashMap();
$shmMaster->create($masterKey);
$shmMaster->set('hello','world');
// add key to salver
$shmSalver = new Yangyao\ShmCache\ShmHashMap();
$shmSalver->create($salverKey);
$shmSalver->set('hello','world');
// use the reader
Yangyao\ShmCache\Reader::init($masterKey,$salverKey);
Yangyao\ShmCache\Reader::get($key);
```

cluster consistent

```
$server_1 = 0x2222;
$server_2 = 0x2223;

$key = 'hello';

$consistent = new Yangyao\ShmCache\ConsistentHash();
$consistent->addServer($server_1);
$consistent->addServer($server_2);

$server = $consistent->find($key);

$shm = new Yangyao\ShmCache\ShmHashMap();
$shm->attach($server);

// $shm->set($key,'world');

$data = $shm->get($key);
```

what's the principle ?
----------------------

[](#whats-the-principle-)

- based on hash arithmetic
- write data into share memory use php shmop extension

what's the data structure ?
---------------------------

[](#whats-the-data-structure-)

head

[![head](https://user-images.githubusercontent.com/5866775/55677531-2965bb00-591c-11e9-8527-cde171b53b28.png)](https://user-images.githubusercontent.com/5866775/55677531-2965bb00-591c-11e9-8527-cde171b53b28.png)

data

[![data](https://user-images.githubusercontent.com/5866775/55677532-29fe5180-591c-11e9-8a37-5eb8682fe46e.png)](https://user-images.githubusercontent.com/5866775/55677532-29fe5180-591c-11e9-8a37-5eb8682fe46e.png)

all

[![all](https://user-images.githubusercontent.com/5866775/55725786-f5d08100-5a40-11e9-805e-e2dfa3c6cdd6.png)](https://user-images.githubusercontent.com/5866775/55725786-f5d08100-5a40-11e9-805e-e2dfa3c6cdd6.png)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/yangyao-shm-cache/health.svg)

```
[![Health](https://phpackages.com/badges/yangyao-shm-cache/health.svg)](https://phpackages.com/packages/yangyao-shm-cache)
```

###  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)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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