PHPackages                             ecomdev/magento-psr6-bridge - 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. ecomdev/magento-psr6-bridge

ActiveMagento2-module

ecomdev/magento-psr6-bridge
===========================

A bridge between Magento framework and PSR-6 cache compatible libraries.

0.2.1(9y ago)1346.7k↓32%3OSL-3.0PHPPHP ~5.6|&gt;=7.0

Since May 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/EcomDev/magento-psr6-bridge)[ Packagist](https://packagist.org/packages/ecomdev/magento-psr6-bridge)[ RSS](/packages/ecomdev-magento-psr6-bridge/feed)WikiDiscussions master Synced 1mo ago

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

Magento 2.0 PSR-6 Bridge [![Build Status](https://camo.githubusercontent.com/900c983bf12624416b60e8adaa6df7c34f9066154c08ff62986e1acb7f5bb9e3/68747470733a2f2f7472617669732d63692e6f72672f45636f6d4465762f6d6167656e746f2d707372362d6272696467652e737667)](https://travis-ci.org/EcomDev/magento-psr6-bridge) [![Coverage Status](https://camo.githubusercontent.com/4d976b3b0adc011e077431efeff49f468725ae0840930b25a9cbdc37902a8790/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f45636f6d4465762f6d6167656e746f2d707372362d6272696467652f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/EcomDev/magento-psr6-bridge?branch=develop)
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#magento-20-psr-6-bridge---)

This small module is a bridge, that allows you to integrate any PSR-6 compatible library into your Magento 2.0 project.

As well it is more convenient to use PSR-6 based cache pool than creating your custom cache type for a Magento module.

[Read more about PSR-6](http://www.php-fig.org/psr/psr-6/)

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

[](#installation)

1. Add module as dependency:

    ```
    composer require ecomdev/magento-psr6-bridge
    ```
2. Enable module

    ```
    bin/magento module:enable EcomDev_MagentoPsr6Bridge
    ```
3. Enable PSR-6 cache type

    ```
    bin/magento cache:enable psr6
    ```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

If you already have a PSR-6 compatible library, that uses `Psr\Cache\CacheItemPoolInterface` in one of its components, it will work out of the box. All the cache keys will be automatically prefixed with `psr6_` prefix in standard Magento cache storage. Also PSR6 cache tag will be applied automatically.

### Using custom cache tags and prefix

[](#using-custom-cache-tags-and-prefix)

If you would like to implement own cache invalidation on particular actions (ERP import, etc).

Then you might find it convenient to use additional custom cache tags so items will be cleaned by them on invoking `clear()` method.

1. Add a new virtual type into your `di.xml` and use it for your instances

    ```

                    CUSTOM_TAG

                my_custom_prefix

                yourModuleCustomCacheItemPoolInstance

    ```
2. Now you can use it in your custom class

    ```
    namespace Your\Module\Model;

    class Item
    {
        private $cacheItemPool;

        public function __construct(
            \Psr\Cache\CacheItemPoolInterface $cacheItemPool
        )
        {
            $this->cacheItemPool = $cacheItemPool;
        }

        public function doSomeStuff()
        {
            $item = $this->cacheItemPool->getItem('cache_key_id');

            if ($item->isHit()) {
                return sprintf('Cached: %s', $item->get());
            }

            $value = 'Value for cache';

            $item->set($value);

            $this->cacheItemPool->save($item);

            return sprintf('Not cached: %s', $value);
        }

        public function invalidate()
        {
            $this->cacheItemPool->clear();
            return $this;
        }

    }
    ```

### Use cache key generator

[](#use-cache-key-generator)

Modules comes out of the box with properly configured cache key generator, so if you do not want to take care about your cache key structure, but have PSR6 compatible, you can use it:

```
namespace Your\Module\Model;

use EcomDev\CacheKey\InfoProviderInterface;

class Item implements InfoProviderInterface
{
    private $cacheItemPool;

    private $cacheKeyGenerator;

    public function __construct(
        \Psr\Cache\CacheItemPoolInterface $cacheItemPool,
        \EcomDev\CacheKey\GeneratorInterface $cacheKeyGenerator
    )
    {
        $this->cacheItemPool = $cacheItemPool;
        $this->cacheKeyGenerator = $cacheKeyGenerator;
    }

    public function getCacheKeyInfo()
    {
        return [
            'key' => 'value',
            'key1' => 'value1'
        ];
    }

    public function doSomeStuff()
    {
        $item = $this->cacheItemPool->getItem(
            $this->cacheKeyGenerator->generate($this)
        );

        if ($item->isHit()) {
            return sprintf('Cached: %s', $item->get());
        }

        $value = 'Value for cache';
        $item->set($value);

        $this->cacheItemPool->save($item);

        return sprintf('Not cached: %s', $value);
    }
}
```

This allows you remove all that terrible logic of cache key generation based on your class properties.

[Read more about cache key generator](https://github.com/ecomdev/cache-key)

Contribution
------------

[](#contribution)

Make a pull request based on develop branch

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

3639d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/190d12eae43e0d874394cbc7fc49ea94c6b6e1bc8b05f75b94fbd0b9c4b5d15f?d=identicon)[IvanChepurnyi](/maintainers/IvanChepurnyi)

---

Top Contributors

[![IvanChepurnyi](https://avatars.githubusercontent.com/u/866758?v=4)](https://github.com/IvanChepurnyi "IvanChepurnyi (20 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/ecomdev-magento-psr6-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/ecomdev-magento-psr6-bridge/health.svg)](https://phpackages.com/packages/ecomdev-magento-psr6-bridge)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.3k86.3M2.2k](/packages/symfony-symfony)[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[symfony/cache

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

4.2k348.9M2.5k](/packages/symfony-cache)[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)

PHPackages © 2026

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