PHPackages                             marvin255/in-memory-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. marvin255/in-memory-cache

ActiveLibrary[Caching](/categories/caching)

marvin255/in-memory-cache
=========================

Array based cache for PHP

v3.0.3(2mo ago)02.1k[1 PRs](https://github.com/marvin255/in-memory-cache/pulls)1MITPHPPHP &gt;=8.3CI passing

Since May 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/marvin255/in-memory-cache)[ Packagist](https://packagist.org/packages/marvin255/in-memory-cache)[ RSS](/packages/marvin255-in-memory-cache/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (12)Versions (19)Used By (1)

InMemoryCache
=============

[](#inmemorycache)

[![Build Status](https://github.com/marvin255/in-memory-cache/workflows/marvin255_in_memory_cache/badge.svg)](https://github.com/marvin255/in-memory-cache/actions?query=workflow%3A%22marvin255_in_memory_cache%22)

Simple [PSR-16](https://www.php-fig.org/psr/psr-16/) implementation that uses an internal array to store data.

Usage
-----

[](#usage)

```
use Marvin255\InMemoryCache\InMemoryCache;

$maxCacheSize = 10000;  // only 10000 can be stored by this object
$defaultTTL = 60;       // 60 seconds as default TTL

$cache = new InMemoryCache($maxCacheSize, $defaultTTL);
```

Decorator
---------

[](#decorator)

The decorator allows you to use two caches at the same time. All data from the base cache (e.g. a Redis-based cache) will also be stored in InMemoryCache. This decorator can reduce the number of requests for long-running PHP processes.

```
use Marvin255\InMemoryCache\InMemoryCache;
use Marvin255\InMemoryCache\CompositeCache;

$maxCacheSize = 10000;  // only 10000 can be stored by this object
$defaultTTL = 60;       // 60 seconds as default TTL

$inMemoryCache = new InMemoryCache($maxCacheSize, $defaultTTL);
$redisCache = new MyAwesomeRedisCache();
$decorator = new CompositeCache($inMemoryCache, $redisCache);

$decorator->get('test'); // this call will trigger a request to Redis and save the data to memory
$decorator->get('test'); // this call won't trigger any requests and will just return data from memory
```

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance89

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% 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 ~119 days

Total

16

Last Release

81d ago

Major Versions

v1.0.2 → v2.0.02022-03-11

v2.3.3 → v3.0.02025-05-10

PHP version history (4 changes)v1.0.0PHP &gt;=7.4

v2.0.0PHP &gt;=8.0

v2.1.0PHP &gt;=8.1

v3.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c29b776ac327dcfcdfc20619a65826ad94a0cb554503386fb080299edfbe3e8?d=identicon)[marvin255](/maintainers/marvin255)

---

Top Contributors

[![marvin255](https://avatars.githubusercontent.com/u/2802915?v=4)](https://github.com/marvin255 "marvin255 (25 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

cachephppsr-16phpcache

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marvin255-in-memory-cache/health.svg)

```
[![Health](https://phpackages.com/badges/marvin255-in-memory-cache/health.svg)](https://phpackages.com/packages/marvin255-in-memory-cache)
```

###  Alternatives

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1067.2M145](/packages/laminas-laminas-cache)[voku/simple-cache

Simple Cache library

322.6M9](/packages/voku-simple-cache)

PHPackages © 2026

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