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 2mo 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 14% 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

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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