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

AbandonedArchivedLibrary[Caching](/categories/caching)

phossa2/cache
=============

A PSR-6 compliant PHP caching library

2.0.1(9y ago)3221MITPHPPHP ~5.4|~7.0

Since Aug 17Pushed 6y ago1 watchersCompare

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

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

phossa2/cache \[ABANDONED\]
===========================

[](#phossa2cache-abandoned)

Please use [phoole/cache](https://github.com/phoole/cache) instead.

[![Build Status](https://camo.githubusercontent.com/11a0c75012806c6309dc2cc4d4c04ea12607eb0ed46c8730d0ef1ec2ae708c99/68747470733a2f2f7472617669732d63692e6f72672f70686f737361322f63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phossa2/cache)[![Code Quality](https://camo.githubusercontent.com/01a11ea7357f8dccc854dc90d06cbb070b4f242c02621e569bd4a970c24c057d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70686f737361322f63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phossa2/cache/)[![Code Climate](https://camo.githubusercontent.com/923fb41f28c0f934af6a01e5a458dfe997eecac6a5e40a1041ddfa9ba961e7c7/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f70686f737361322f63616368652f6261646765732f6770612e737667)](https://codeclimate.com/github/phossa2/cache)[![PHP 7 ready](https://camo.githubusercontent.com/93f888d093182e366db861be490be65f8cb254997f56850e82f3ac38acdb0b01/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f70686f737361322f63616368652f6d61737465722f62616467652e737667)](https://travis-ci.org/phossa2/cache)[![HHVM](https://camo.githubusercontent.com/ef065c4326f5dcfcd01951e3ab004ccd69008ff0b1e340e2180e270ad375e0d3/68747470733a2f2f696d672e736869656c64732e696f2f6868766d2f70686f737361322f63616368652e7376673f7374796c653d666c6174)](http://hhvm.h4cc.de/package/phossa2/cache)[![Latest Stable Version](https://camo.githubusercontent.com/c7567d0fa3dd07ca7a02014e7545c61ed7ae7391426df5a2f06e582bf91faf8e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f70686f737361322f63616368652e7376673f7374796c653d666c6174)](https://packagist.org/packages/phossa2/cache)[![License](https://camo.githubusercontent.com/4fc6538ded72843e26a272d300ce4c95da083ce92576e10e4fdd505d579a8125/68747470733a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e737667)](http://mit-license.org/)

**phossa2/cache** is a PSR-6 compliant caching library for PHP. It supports various drivers and useful features like bypass, encrypt, stampede protection etc.

It requires PHP 5.4, supports PHP 7.0+ and HHVM. It is compliant with [PSR-1](http://www.php-fig.org/psr/psr-1/ "PSR-1: Basic Coding Standard"), [PSR-2](http://www.php-fig.org/psr/psr-2/ "PSR-2: Coding Style Guide"), [PSR-3](http://www.php-fig.org/psr/psr-3/ "PSR-3: Logger Interface"), [PSR-4](http://www.php-fig.org/psr/psr-4/ "PSR-4: Autoloader"), [PSR-6](http://www.php-fig.org/psr/psr-6/ "PSR-6: Caching Interface") and the proposed [PSR-5](https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md "PSR-5: PHPDoc").

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

[](#installation)

Install via the `composer` utility.

```
composer require "phossa2/cache"
```

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

```
{
    "require": {
       "phossa2/cache": "2.*"
    }
}
```

Features
--------

[](#features)

- Fully [PSR-6](http://www.php-fig.org/psr/psr-6/ "PSR-6: Caching Interface") compliant.
- Support all serializable PHP datatypes.
- **Extensions included**:

    - **Bypass**: If sees a trigger in URL (e.g. '?nocache=true'), bypass the cache.
    - **Stampede Protection**: Whenever cached object's lifetime is less than a configurable time, by a configurable percentage, the cache will return false on 'isHit()' which will trigger re-generation of the object.
    - **Encrypt**: A simple extension to encrypt the serialized content.
    - **DistributedExpiration**: Even out the spikes of item misses by alter expiration time a little bit.
- **Drivers**

    - **StorageDriver**

        The storage driver uses [phossa2/storage](https://github.com/phossa2/storage)local or cloud storage.
    - **NullDriver**

        The blackhole driver, can be used as fallback driver for all other drivers.

Usage
-----

[](#usage)

- Simple usage

    ```
    /*
     * cache dir default to local sys_get_temp_dir() . '/cache'
     */
    $cache = new CachePool();

    $item = $cache->getItem('/data.cache');
    if (!$item->isHit()) {
        $value = calcuate_data();
        $item->set($value);
        $cache->save($item);
    }
    $data = $item->get();
    ```
- Specify the driver

    ```
    use Phossa2\Cache\Driver\StorageDriver;
    use Phossa2\Storage\Storage;
    use Phossa2\Storage\Filesystem;
    use Phossa2\Storage\Driver\LocalDriver;

    $driver = new StorageDriver(
        new Storage('/', new Filesystem(new LocalDriver(sys_get_temp_dir()))),
        '/cache'
    );

    $cache = new CachePool($driver);
    ```
- Use extensions

    ```
    /*
     * DistributedExpiration extension
     */
    use Phossa2\Cache\CachePool;
    use Phossa2\Cache\Extension\DistributedExpiration;

    $cache = new CachePool();
    $cache->addExtension(new DistributedExpiration());
    ```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) from more information.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTE](CONTRIBUTE.md) for more information.

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

[](#dependencies)

- PHP &gt;= 5.4.0
- [phossa2/event](https://github.com/phossa2/event) &gt;= 2.1.4
- [phossa2/storage](https://github.com/phossa2/storage) &gt;= 2.0.0

License
-------

[](#license)

[MIT License](http://mit-license.org/)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% 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

2

Last Release

3588d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19922046?v=4)[Hong Zhang](/maintainers/phossa2)[@phossa2](https://github.com/phossa2)

---

Top Contributors

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

---

Tags

cachecachingpsr-6phossa

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k365.0M3.1k](/packages/symfony-cache)[tedivm/stash

The place to keep your cache.

9614.9M126](/packages/tedivm-stash)[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)[cache/adapter-common

Common classes for PSR-6 adapters

11025.1M38](/packages/cache-adapter-common)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2514.6M10](/packages/beste-in-memory-cache)[cache/hierarchical-cache

A helper trait and interface to your PSR-6 cache to support hierarchical keys.

6016.5M11](/packages/cache-hierarchical-cache)

PHPackages © 2026

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