PHPackages                             chillerlan/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. [Caching](/categories/caching)
4. /
5. chillerlan/php-cache

ActiveLibrary[Caching](/categories/caching)

chillerlan/php-cache
====================

A psr/simple-cache implementation. PHP 8.1+

5.1.0(2y ago)15211.8k↓38%39MITPHPPHP ^8.1

Since May 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/chillerlan/php-cache)[ Packagist](https://packagist.org/packages/chillerlan/php-cache)[ Docs](https://github.com/chillerlan/php-cache)[ Fund](https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4)[ Fund](https://ko-fi.com/codemasher)[ RSS](/packages/chillerlan-php-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (12)Used By (9)

chillerlan/php-cache
====================

[](#chillerlanphp-cache)

A psr/simple-cache implementation for PHP 8.1+.

[![PHP Version Support](https://camo.githubusercontent.com/6df673dd8c44c7be548bd37153d5086384e5cb30d46e24ff170034296fd9c081/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6368696c6c65726c616e2f7068702d63616368653f6c6f676f3d70687026636f6c6f723d383839324246)](https://www.php.net/supported-versions.php)[![version](https://camo.githubusercontent.com/314a538cb86f93642fdd2d7c715972afb5a20c317b5a4c05ecfff2ebe8259ba7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696c6c65726c616e2f7068702d63616368652e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-cache)[![license](https://camo.githubusercontent.com/81ab1acbc77a4b8000c0804117ffcfca913d7d05d1ea0920dba376dcd6b2749f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6368696c6c65726c616e2f7068702d63616368652e737667)](https://github.com/chillerlan/php-cache/blob/master/LICENSE)[![Coverage](https://camo.githubusercontent.com/2562c4ef780ac8b1698f8001f7bb5b398223a85cda955b20636e5c07ba380bbf/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6368696c6c65726c616e2f7068702d63616368652e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/github/chillerlan/php-cache)[![Codacy](https://camo.githubusercontent.com/920615d93d4d5c52d0218b33fc0de2d4433d06efc1d95e853705ab552307b4dc/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f36396231396261383161653634393266393733633466303562393238383461612f6d61696e3f6c6f676f3d636f64616379)](https://app.codacy.com/gh/chillerlan/php-cache/dashboard?branch=main)[![Packagist downloads](https://camo.githubusercontent.com/4eca3379c20a648c914c98de96aa19b7df54ae2778f5fbf0dfd9329f5915f9cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696c6c65726c616e2f7068702d63616368652e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-cache/stats)
[![Continuous Integration](https://github.com/chillerlan/php-cache/workflows/Continuous%20Integration/badge.svg)](https://github.com/chillerlan/php-cache/actions)

Features:
---------

[](#features)

- [PSR-16 simple-cache-implementation](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md)
    - persistent: File based, Memcached, Redis
    - non-persistent: Session, Memory

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

[](#requirements)

- **PHP 8.1+**
    - optionally one of the following extensions
        - [Memcached](https://www.php.net/manual/en/book.memcached.php)
        - [Redis](https://github.com/phpredis/phpredis/)
        - [APCU](https://www.php.net/manual/en/book.apcu.php)

Documentation
-------------

[](#documentation)

### Installation using [composer](https://getcomposer.org)

[](#installation-using-composer)

You can simply clone the repo and run `composer install` in the root directory. In case you want to include it elsewhere, just add the following to your *composer.json*:

(note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^4.1` - see [releases](https://github.com/chillerlan/php-cache/releases) for valid versions)

```
{
	"require": {
		"php": "^8.1",
		"chillerlan/php-cache": "dev-main"
	}
}
```

Installation via terminal: `composer require chillerlan/php-cache`

Profit!

### Usage

[](#usage)

Just invoke a cache instance with the desired `CacheInterface` like so:

```
// Redis
$redis = new Redis;
$redis->pconnect('127.0.0.1', 6379);

$cache = new RedisCache($redis);

// Memcached
$memcached = new Memcached('myCacheInstance');
$memcached->addServer('localhost', 11211);

$cache = new MemcachedCache($memcached);

// APCU
$cache = new APCUCache;

// File
$cache = new FileCache(new CacheOptions(['cacheFilestorage' => __DIR__.'/../.cache']));

// Session
$cache = new SessionCache(new CacheOptions(['cacheSessionkey' => '_my_session_cache']));

// Memory
$cache = new MemoryCache;
```

#### Methods

[](#methods)

See: [`Psr\SimpleCache\CacheInterface`](https://github.com/php-fig/simple-cache/blob/master/src/CacheInterface.php)

```
$cache->get(string $key, $default = null); // -> mixed
$cache->set(string $key, $value, int $ttl = null):bool
$cache->delete(string $key):bool
$cache->has(string $key):bool
$cache->clear():bool
$cache->getMultiple(array $keys, $default = null):array // -> mixed[]
$cache->setMultiple(array $values, int $ttl = null):bool
$cache->deleteMultiple(array $keys):bool
```

Disclaimer!
-----------

[](#disclaimer)

I don't take responsibility for molten memory modules, bloated hard disks, self-induced DoS, broken screens etc. Use at your own risk! 🙈

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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 ~246 days

Recently: every ~352 days

Total

11

Last Release

813d ago

Major Versions

1.0.2 → 2.0.02018-08-08

2.0.0 → 3.0.02018-10-23

3.1.0 → 4.0.02020-04-16

4.1.0 → 5.0.02024-02-15

v4.x-dev → 5.1.02024-02-25

PHP version history (5 changes)1.0.0PHP &gt;=7.0.3

2.0.0PHP ^7.2

4.0.0PHP ^7.4

4.1.0PHP ^7.4 || ^8.0

5.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![codemasher](https://avatars.githubusercontent.com/u/592497?v=4)](https://github.com/codemasher "codemasher (109 commits)")[![bahramsadin](https://avatars.githubusercontent.com/u/24217539?v=4)](https://github.com/bahramsadin "bahramsadin (1 commits)")[![lucidlemon](https://avatars.githubusercontent.com/u/2458762?v=4)](https://github.com/lucidlemon "lucidlemon (1 commits)")

---

Tags

cachememcachedphpphp-libraryphp7psr-16redissimple-cachecachepsr-16php8

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[laminas/laminas-cache

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

1076.9M130](/packages/laminas-laminas-cache)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

423.1M27](/packages/cache-simple-cache-bridge)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[webarchitect609/bitrix-cache

Comfortable fluent interface for Bitrix cache. Anti-stampede cache protection.

2831.2k8](/packages/webarchitect609-bitrix-cache)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[codeigniter4/cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

1320.1k](/packages/codeigniter4-cache)

PHPackages © 2026

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