PHPackages                             nabeghe/mem - 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. nabeghe/mem

ActiveLibrary[Caching](/categories/caching)

nabeghe/mem
===========

A cool real-time cache using static variable that lets you group keys.

v1.2.0(1y ago)44MITPHPPHP &gt;=5.6

Since Oct 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nabeghe/mem-php)[ Packagist](https://packagist.org/packages/nabeghe/mem)[ Docs](https://github.com/nabeghe/mem-php)[ RSS](/packages/nabeghe-mem/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Mem (Simple Realtime Cache for PHP)
===================================

[](#mem-simple-realtime-cache-for-php)

> A cool real-time cache using static variable that lets you group keys.

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/mem
```

### Methods Syntax

[](#methods-syntax)

```
// Checks if a key exists in a cache group.
Mem::has(mixed $key, mixed $group = 'default'): bool

// Returns the first key of an item that matches the regex.
Mem::match($regex, $group = 'default'): ?string

// Returns items whose keys match the regex.
Mem::matches($regex, $group = 'default'): ?array

// Checks if a group exists.
Mem::hasGroup(mixed $group): bool

// Returns the value of a key from a group.
Mem::get(mixed $key, mixed $group = 'default', mixed $default = null): bool

// Changes the value of a key in a group.
Mem::set(mixed $key, mixed $value, mixed $group = 'default'): bool

// Deletes a key from a group.
Mem::del($key, $group = 'default'): bool

// Deletes items based on key matching with regex.
Mem::delMatches($regex, $group = 'default'): bool

// Returns all storages (groups) and their keys.
Mem::all(): array

// Returns all keys and values of a group.
Mem::group($group = 'default'): Storage

// Returns the number of existing groups.
Mem::groupsCount(): int

// Clears the entire group.
Mem::drop($group = 'default'): bool

// Clears the entire cache.
Mem::reset(): bool
```

### Configuration

[](#configuration)

The `config` method is used for configuration, with the first argument being the group name &amp; the second argument as an array to config that group. If the second argument is `false` or not set, it returns the current config.

The `configProp` method retrieves a key's value from the config, with the key and group name as parameters.

The default config value is in `DEFAULT_CONFIG` const.

Currently, there's only one configuration, `length_limit`, with a default value of `-1`, which defines the group size. When the item count exceeds this, the first item is removed. `-1` means unlimited, also, `0` is currently not useful &amp; should not be used.

```
Mem::config('default', ['length_limit' => 3]);

Mem::set('item_1', 'value 1');
Mem::set('item_2', 'value 2');
Mem::set('item_3', 'value 3');
Mem::set('item_4', 'value 4');

/*
 * Items in the default group:
 *  [
 *      'item_2' => 'value 2',
 *      'item_3' => 'value 3',
 *      'item_4' => 'value 4'
 *  ]
 */
```

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance45

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

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

Every ~48 days

Total

3

Last Release

523d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12207627?v=4)[Hadi Akbarzadeh](/maintainers/nabeghe)[@nabeghe](https://github.com/nabeghe)

---

Top Contributors

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

---

Tags

cachecachingcaching-libhelperlibraryphpphp-cachephp-cacherphp-helperphp-libraryphp-memcachedphp-memoryrealtimestatichelperlibrarycachecachingmemorystaticrealtimesupportstatic-cachememory cacherealtime cache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nabeghe-mem/health.svg)

```
[![Health](https://phpackages.com/badges/nabeghe-mem/health.svg)](https://phpackages.com/packages/nabeghe-mem)
```

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

445131.2M46](/packages/react-cache)[silverstripe/staticpublishqueue

Static publishing queue to create static versions of pages for enhanced performance and security

44140.1k6](/packages/silverstripe-staticpublishqueue)[putyourlightson/craft-blitz

Intelligent static page caching for creating lightning-fast sites.

155484.7k37](/packages/putyourlightson-craft-blitz)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15195.9k7](/packages/rapidwebltd-rw-file-cache)[jord-jd/do-file-cache

DO File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

1510.3k4](/packages/jord-jd-do-file-cache)

PHPackages © 2026

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