PHPackages                             phoole/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. phoole/cache

ActiveLibrary[Caching](/categories/caching)

phoole/cache
============

Slim and full compatible PSR-16 cache library for PHP

1.1.0(6y ago)42451Apache-2.0PHPPHP &gt;=7.2.0CI failing

Since Oct 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phoole/cache)[ Packagist](https://packagist.org/packages/phoole/cache)[ RSS](/packages/phoole-cache/feed)WikiDiscussions master Synced 4d ago

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

cache
=====

[](#cache)

[![Build Status](https://camo.githubusercontent.com/a590d19372326be373770f89fac9cf97d0f7ef637c29c25301f29e99ea7ad17a/68747470733a2f2f7472617669732d63692e636f6d2f70686f6f6c652f63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/phoole/cache)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f299c1df6f58595a1dd36bc7a1e554b1841f7cafd01da2846fd4caf7f9c4847c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70686f6f6c652f63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phoole/cache/?branch=master)[![Code Climate](https://camo.githubusercontent.com/43dcd46183ef5dea363012e1130cd694f529f5a024bbbadb54c706d0183442b0/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f70686f6f6c652f63616368652f6261646765732f6770612e737667)](https://codeclimate.com/github/phoole/cache)[![PHP 7](https://camo.githubusercontent.com/49b5531cbb184488ec968298403cf8a7589534e31aed4999344cea264988591e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f70686f6f6c652f6361636865)](https://packagist.org/packages/phoole/cache)[![Latest Stable Version](https://camo.githubusercontent.com/8221222e4fb7413819f1773ce79abbdfda7747d833ce1c76950185dd5782e34f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f70686f6f6c652f6361636865)](https://packagist.org/packages/phoole/cache)![License](https://camo.githubusercontent.com/9e51b9f9f0692fa4fc5de5d2f42b4dc1dfe08ceac680629f39adcbf6758e0151/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70686f6f6c652f6361636865)

Slim and full compatible PSR-16 cache library for PHP

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

[](#installation)

Install via the `composer` utility.

```
composer require "phoole/cache"
```

or add the following lines to your `composer.json`

```
{
    "require": {
       "phoole/cache": "1.1.*"
    }
}
```

Features
--------

[](#features)

- Fully [PSR-16](https://www.php-fig.org/psr/psr-16/) compliant.
- Support all serializable PHP data types.
- Extra features:

    - **Stampede Protection**: Whenever **ONE** cached object's lifetime is less than a configurable `stampedeGap` time in seconds (60s default), by a configurable `stampedePercent` (5% default) percentage, it will be considered stale. It may then trigger generating new cache depend on your decision. This feature is quite useful for reducing a single hot item stampede situation.

        ```
        // overwrite stampede defaults
        $cache = new Cache($fileAdatpor, [
            'stampedeGap' => 120,   // 120second
            'stampedePercent' => 2  // 2%
        ]);
        ```
    - **Distributed expiration**: By setting `distributedPercent` (5% default) to a reasonable percentage, system will store each cache item with its TTL(time to live) a small random fluctuation. This will help avoiding large amount of items expired at the same time.

        ```
        $cache = new Cache($fileAdaptor, [
            'distributedPercent' => 3,   // 3%, default is 5%
        ]);
        ```
- `CacheAwareInterface` and `CacheAwareTrait`

Usage
-----

[](#usage)

- Simple usage

    ```
    use Phoole\Cache\Cache;

    // using default adaptor and default settings
    $cache = new Cache();

    // get with default value 'phoole'
    $name  = $cache->get('name', 'phoole');

    // set cache
    $cache->set('name', 'wow');
    ```
- Specify the adaptor

    ```
    use Phoole\Cache\Cache;
    use Phoole\Cache\Adaptor\FileAdaptor;

    // use file adaptor and specific cache directory
    $cache = new Cache(new FileAdaptor('/tmp/cache');
    ```
- Use with [dependency injection](https://github.com/phoole/di)

    ```
    use Phoole\Cache\Cache;
    use Phoole\Di\Container;
    use Phoole\Config\Config;

    // config cache in the container
    $container = new Container(new Config(
        'di.service' => [
            'cache' => Cache::class
        ],
    ));

    // get from container
    $cache = $container->get('cache');

    // or static FACADE way
    $cache = Container::cache();
    ```

Testing
-------

[](#testing)

```
$ composer test
```

Dependencies
------------

[](#dependencies)

- PHP &gt;= 7.2.0
- [phoole/base](https://github.com/phoole/base) 1.\*

License
-------

[](#license)

- [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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 ~8 days

Total

4

Last Release

2371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bae7d5f135e90fd05271574bfd04d4844169bd4c554eaa9e103e4af69267ffc?d=identicon)[phoole](/maintainers/phoole)

---

Top Contributors

[![phossa](https://avatars.githubusercontent.com/u/8499165?v=4)](https://github.com/phossa "phossa (11 commits)")[![phoole](https://avatars.githubusercontent.com/u/55728163?v=4)](https://github.com/phoole "phoole (1 commits)")

---

Tags

cachephoolephppsr-16simple-cacheswoolephplibrarycachepsr-16swoolephoole

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/phoole-cache/health.svg)](https://phpackages.com/packages/phoole-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)[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.

15191.3k7](/packages/rapidwebltd-rw-file-cache)

PHPackages © 2026

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