PHPackages                             ez-php/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. [Framework](/categories/framework)
4. /
5. ez-php/cache

ActiveLibrary[Framework](/categories/framework)

ez-php/cache
============

Cache module for the ez-php framework — array, file, and Redis drivers with a unified interface

1.11.1(1mo ago)03.2k↓90%3MITPHPPHP ^8.5CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/cache)[ Packagist](https://packagist.org/packages/ez-php/cache)[ Docs](https://github.com/ez-php/cache)[ RSS](/packages/ez-php-cache/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (16)Versions (43)Used By (3)

ez-php/cache
============

[](#ez-phpcache)

Cache module for the [ez-php framework](https://github.com/ez-php/framework) — array, file, Redis, and Memcached drivers with a unified interface, tagging, locking, cache statistics, and stampede protection.

[![CI](https://github.com/ez-php/cache/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/cache/actions/workflows/ci.yml)

Requirements
------------

[](#requirements)

- PHP 8.5+
- ez-php/framework 0.\*
- ext-redis (for Redis driver)
- ext-memcached (for Memcached driver)

Installation
------------

[](#installation)

```
composer require ez-php/cache
```

Setup
-----

[](#setup)

Register the service provider:

```
$app->register(\EzPhp\Cache\CacheServiceProvider::class);
```

Configure in `config/cache.php`:

```
return [
    'driver'    => env('CACHE_DRIVER', 'array'), // array | file | redis | memcached
    'file_path' => storage_path('cache'),
    'redis'     => [
        'host'     => env('REDIS_HOST', '127.0.0.1'),
        'port'     => (int) env('REDIS_PORT', 6379),
        'database' => (int) env('REDIS_DATABASE', 0),
    ],
    'memcached' => [
        'host' => env('MEMCACHED_HOST', '127.0.0.1'),
        'port' => (int) env('MEMCACHED_PORT', 11211),
    ],
];
```

Usage
-----

[](#usage)

### Basic operations

[](#basic-operations)

```
$cache = $app->make(\EzPhp\Cache\CacheInterface::class);

$cache->set('key', 'value', ttl: 3600);
$value  = $cache->get('key', 'default');
$cache->forget('key');
$cache->has('key');
$result = $cache->remember('key', 60, fn () => expensiveComputation());
$cache->flush();
```

### Tagging

[](#tagging)

```
$tagged = $cache->tags('users');
$tagged->set('profile:42', $profile, 300);
$tagged->flush(); // invalidates all keys tagged with 'users'
```

### Locking

[](#locking)

```
$lock = $cache->lock('process-payments', ttl: 30);
if ($lock->acquire()) {
    try {
        // critical section
    } finally {
        $lock->release();
    }
}
```

### Stampede protection

[](#stampede-protection)

```
use EzPhp\Cache\StampedeProtectedCache;

$protected = new StampedeProtectedCache($cache);
$value = $protected->remember('expensive-key', 300, fn () => heavyQuery());
```

Drivers
-------

[](#drivers)

Driver`CACHE_DRIVER`Notes`array``array`In-memory, request lifetime only`file``file`Filesystem, serialised entries`redis``redis`Via `ext-redis`; `flush()` clears entire database`memcached``memcached`Via `ext-memcached`; `flush()` clears entire serverClasses
-------

[](#classes)

ClassDescription`CacheInterface`Unified contract: `get`, `set`, `forget`, `has`, `remember`, `flush``ArrayDriver`In-memory driver`FileDriver`Filesystem driver with MD5-keyed files`RedisDriver`Redis driver via `ext-redis`; native TTL`MemcachedDriver`Memcached driver via `ext-memcached``FileLock` / `ArrayLock` / `RedisLock` / `MemcachedLock`Driver-specific lock implementations`TaggableDriverTrait`Provides `tags()` → `TaggedCache` for all drivers`TaggedCache`Scoped cache view: keys prefixed with tag hash`CacheStats`Immutable value object: hits, misses`StampedeProtectedCache`Decorator: probabilistic early recompute to prevent stampedes`CacheServiceProvider`Config-driven driver bindingLicense
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance91

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% 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 ~1 days

Total

42

Last Release

43d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122030400?v=4)[AU9500](/maintainers/AU9500)[@AU9500](https://github.com/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (136 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

phpframeworkrediscacheez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-cache/health.svg)

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

###  Alternatives

[utopia-php/cache

A simple cache library to manage application cache storing, loading and purging

31447.6k15](/packages/utopia-php-cache)[mirekmarek/php-jet

PHP Jet is modern, powerful, real-life proven, really fast and secure, small and light-weight framework for PHP8 with great clean and flexible modular architecture containing awesome developing tools. No magic, just clean software engineering.

241.3k](/packages/mirekmarek-php-jet)

PHPackages © 2026

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