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)15227.4k↓48.6%39MITPHPPHP ^8.1CI failing

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 3d 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

45

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community22

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

860d 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://avatars.githubusercontent.com/u/592497?v=4)[smiley](/maintainers/codemasher)[@codemasher](https://github.com/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

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[laminas/laminas-cache

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

1077.3M154](/packages/laminas-laminas-cache)

PHPackages © 2026

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