PHPackages                             ho-nl-fork/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. [Caching](/categories/caching)
4. /
5. ho-nl-fork/magento-psr6-bridge

ActiveMagento2-module[Caching](/categories/caching)

ho-nl-fork/magento-psr6-bridge
==============================

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

0.2.1(1mo ago)0251OSL-3.0PHPPHP ~5.6|&gt;=7.0

Since Apr 29Pushed 1mo agoCompare

[ Source](https://github.com/ho-nl-fork/magento-psr6-bridge)[ Packagist](https://packagist.org/packages/ho-nl-fork/magento-psr6-bridge)[ RSS](/packages/ho-nl-fork-magento-psr6-bridge/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (1)

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

33

—

LowBetter than 73% of packages

Maintenance92

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

41d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15377342?v=4)[honl](/maintainers/honl)[@HonL](https://github.com/HonL)

---

Top Contributors

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

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[symfony/cache

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

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

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M306](/packages/api-platform-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[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)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M180](/packages/api-platform-metadata)

PHPackages © 2026

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