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

ActiveLibrary[Caching](/categories/caching)

ecfectus/cache
==============

A PSR 6 and PHP 7 cache package

011PHP

Since Oct 11Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Cache
=====

[](#cache)

[![Build Status](https://camo.githubusercontent.com/cfd486cfb96d146d2a2ec108e1d29a0901b55c8c587734f62d7c07b2a7396858/68747470733a2f2f7472617669732d63692e6f72672f65636665637475732f63616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ecfectus/cache)

A PSR 6 and PHP 7 cache package using Symfony Cache and inspired by Laravel.

Using our Manager package the cache package provides a simple way to access multiple cache stores.

Each cache store implements the PSR 6 standards, and our own extended CacheItemPoolInterface which contains some simpler access methods to cache stores.

Included Stores are:

null array file apcu pdo redis phpfiles phparray chained

Because our package provides manager functionality you can include your own store simply by adding it to the manager:

```
$cache = new CacheManager($config);

$cache->extend('mystore', function(){

    return new MyStore();//must implement Ecfectus\Cache\CacheItemPoolInterface

});
```

Then to use any of the stores simply call the `store` method:

```
$cache->store('mystore')->get('itemkey', 'default');
```

Or to access the default store, just call the method needed directly on the manager:

```
$cache->get('itemkey', 'default');
```

All PSR6 methods are available on each store, plus our extra [CacheItemPoolInterface](src/CacheItemPoolInterface.php) methods, which remove the verbosity of `CacheItem` objects and simply return the item:

```
$item = $cache->getItem('key');
if($item->isHit()){
    $value = $item->get();
}else{
    $value = 'default';
}

//the same as

$value = $cache->get('key', 'default');
```

Config
------

[](#config)

The configure the cache manager simply provide an array of `store` referencing the default store to use, and an array of `stores`. Below the default configuration for each driver:

```
$config = [
    'store' => 'file',
    'stores' => [
        'array' => [
            'driver' => 'array',
            'lifetime' => 0,
            'serialize' => true
        ],
        'null' => [
            'driver' => 'null'
        ],
        'file' => [
            'driver' => 'file',
            'path' => null,
            'namespace' => '',
            'lifetime' => 0
        ],
        'phpfiles' => [
            'driver' => 'phpfiles',
            'path' => null,
            'namespace' => '',
            'lifetime' => 0
        ],
        'phparray' => [
            'driver' => 'phparray',
            'path' => null,
            'fallback' => 'file'
        ],
        'apcu' => [
            'driver' => 'apcu',
            'namespace' => '',
            'lifetime' => 0,
            'version' => null
        ],
        'pdo' => [
            'driver' => 'pdo',
            'connection' => '',
            'namespace' => '',
            'lifetime' => 0,
            'options' => [
                'db_table' => 'cache_items',
                'db_id_col' => 'item_id',
                'db_data_col' => 'item_data',
                'db_lifetime_col' => 'item_lifetime',
                'db_time_col' => 'item_time',
                'db_username' => '',
                'db_password' => '',
                'db_connection_options' => []
            ]
        ],
        'redis' => [
            'driver' => 'redis',
            'namespace' => '',
            'lifetime' => 0
        ],
        'chain' => [
            'driver' => 'chain',
            'stores' => [
                'array',
                'file'
            ],
            'lifetime' => 0
        ]
    ]
];
```

Each key in the stores array is used to reference the store when accessing via the `store` method, and each store MUST provide a `driver`. All the builtin drivers are referenced above.

Where a connection to either Redis or PDO is needed you can add them to the cache manager with the following methods:

```
$cache->setPdoConnection('connection_name', $pdoInstance);
$cache->setRedisConnection('connection_name', $redisInstance);
```

Now when a `connection` config is needed, you can reference the `connection_name` and it will be used.

You can provide your whole config to the CacheManager instance, only the builtin driver types will be added via `extend`, if your config provides a driver not included in the package you will need to add it yourself via the `extend` method as discussed above.

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b8fdb3cf22dac46100ad95eddb94f98b2a7a5002b29c4d2f812113f2867ff35?d=identicon)[leemason](/maintainers/leemason)

---

Top Contributors

[![leemason](https://avatars.githubusercontent.com/u/1238646?v=4)](https://github.com/leemason "leemason (7 commits)")

### Embed Badge

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

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

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)

PHPackages © 2026

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