PHPackages                             ray/psr-cache-module - 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. ray/psr-cache-module

ActiveLibrary[Caching](/categories/caching)

ray/psr-cache-module
====================

PSR-6 PSR-16 cache module for Ray.Di

1.5.1(6mo ago)1324.6k—6.2%34MITPHPPHP ^8.2CI failing

Since Jul 7Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/ray-di/Ray.PsrCacheModule)[ Packagist](https://packagist.org/packages/ray/psr-cache-module)[ RSS](/packages/ray-psr-cache-module/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (19)Used By (4)

Ray.PsrCacheModule
==================

[](#raypsrcachemodule)

[![codecov](https://camo.githubusercontent.com/e3a228626a0295bf90be98ca6f48ec670ae8177a39a4cc2f27038a177fd54960/68747470733a2f2f636f6465636f762e696f2f67682f7261792d64692f5261792e50737243616368654d6f64756c652f6272616e63682f312e782f67726170682f62616467652e7376673f746f6b656e3d39583377625552725539)](https://codecov.io/gh/ray-di/Ray.PsrCacheModule)[![Type Coverage](https://camo.githubusercontent.com/fd9f6143140c0c4c19d913b27f1cf88e8d1ab8f4676cc2fee700ede04e2c664c/68747470733a2f2f73686570686572642e6465762f6769746875622f7261792d64692f5261792e50737243616368654d6f64756c652f636f7665726167652e737667)](https://shepherd.dev/github/ray-di/Ray.PsrCacheModule)[![Continuous Integration](https://github.com/ray-di/Ray.PsrCacheModule/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/ray-di/Ray.PsrCacheModule/actions/workflows/continuous-integration.yml)[![Psalm level](https://camo.githubusercontent.com/8b267401e572e8d379a7747e37df215dc5727936d9a3030bb694aa5bc1c085f7/68747470733a2f2f73686570686572642e6465762f6769746875622f7261792d64692f5261792e50737243616368654d6f64756c652f6c6576656c2e7376673f)](https://psalm.dev/)

This package is the Ray.Di module that performs the [PSR-6](https://www.php-fig.org/psr/psr-6/) / [PSR-16](https://www.php-fig.org/psr/psr-16/) interface binding.

You can use the PSR6 cache interface in two ways: `Local` and `Public`. `Local` is for caches that do not need to be shared among multiple web servers, and `Public` is for caches that need to be shared.

**PHP8**

```
use Psr\Cache\CacheItemPoolInterface;
use Ray\PsrCacheModule\Annotation\Local;
use Ray\PsrCacheModule\Annotation\Shared;

class Foo
{
    public function __construct(
        #[Local] private CacheItemPoolInterface $localPool,
        #[Shared] private CacheItemPoolInterface $sharedPool
    ){}
}
```

**PHP7.4**

```
use Psr\Cache\CacheItemPoolInterface;
use Ray\PsrCacheModule\Annotation\Local;
use Ray\PsrCacheModule\Annotation\Shared;

class Foo
{
    private CacheItemPoolInterface $localPool;
    private CacheItemPoolInterface $sharedPool;

    /**
     * @Local('localPool')
     * @Shared('sharedPool')
     */
    public function __construct(
        CacheItemPoolInterface $localPool,
        CacheItemPoolInterface $sharedPool
    ){
        $this->localPool = $localPool;
        $this->sharedPool = $sharedPool;
    }
}
```

Create object graph

```
use Ray\Di\AbstractModule;
use Ray\Di\Injector;
use Ray\PsrCacheModule\Psr6ArrayModule;

$foo = (new Injector(new class extends AbstractModule {
    protected function configure()
    {
        $this->install(new Psr6ArrayModule()); // PSR-6
        // $this->install(new Psr16CacheModule()); // PSR-16
    }
}))->getInstance(Foo::class);

assert($foo instanceof Foo);
```

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

[](#installation)

```
composer require ray/psr-cache-module

```

Module install
--------------

[](#module-install)

PSR-6
-----

[](#psr-6)

### Psr6NullModule

[](#psr6nullmodule)

This module is for the development.

- Local: Null
- Shared: Null

```
use Ray\PsrCacheModule\Psr6NullModule;

new Psr6NullModule();
```

### Psr6ArrayModule

[](#psr6arraymodule)

This module is for the development.

- Local: Array
- Shared: Array

```
use Ray\PsrCacheModule\Psr6ArrayModule;

new Psr6ArrayModule();
```

### Psr6ApcuModule

[](#psr6apcumodule)

This module is for a standalone server

- Local: Chain(APC, File)
- Shared: Chain(APC, File)

```
use Ray\PsrCacheModule\Psr6ApcuModule;

new Psr6ApcuModule();
```

### Psr6RedisModule

[](#psr6redismodule)

This module is for multiple servers.

- Local: Chain(APC, File)
- Shared: [Redis](https://github.com/phpredis/phpredis/)

```
use Ray\PsrCacheModule\Psr6RedisModule;

new Psr6RedisModule('redis1:6379:1'); // host:port:dbIndex
```

### Psr6MemcachedModule

[](#psr6memcachedmodule)

This module is for multiple servers.

- Local: Chain(APC, File)
- Shared: [Memcached](https://www.php.net/manual/en/class.memcached.php)

```
use Ray\PsrCacheModule\Psr6MemcachedModule;

new Psr6MemcachedModule('memcached1:11211:60,memcached2:11211:33');  // host:port:weight
```

See

PSR-16
------

[](#psr-16)

If you install Psr16CacheModule, the cache engine installed with Psr6\*Module can be used with PSR-16 interface. PSR-16 bindings use PSR-6 bindings.

```
use Ray\PsrCacheModule\Psr16CacheModule;

new Psr16CacheModule();
```

Common Configuration Module
---------------------------

[](#common-configuration-module)

### CacheDirModule

[](#cachedirmodule)

Specifies the cache directory. Optional.

```
use Ray\PsrCacheModule\CacheDirModule;

new CacheDirModule('path/to/dir');
```

### CacheNamespaceModule

[](#cachenamespacemodule)

Specifies the cache namespace (when multiple applications are placed on a single cache server). Optional.

```
use Ray\PsrCacheModule\CacheNamespaceModule;

new CacheNamespaceModule('app1');
```

### Technical Note

[](#technical-note)

Redis, Memcached classes and symfony/cache adapters are not serializable, but RedisAdapter and MemcachedAdapter, which inherit from symfony/cache and are provided in this package, are.

```
```

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance75

Regular maintenance activity

Popularity38

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% 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 ~99 days

Recently: every ~136 days

Total

17

Last Release

190d ago

PHP version history (3 changes)1.0.0PHP ^7.3 || ^8.0

1.4.0PHP ^8.1

1.5.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/db4fc75ffc631168d0d7143b6f2c24b1534dfb921212bd851c026c5cbbb1344d?d=identicon)[koriym](/maintainers/koriym)

---

Top Contributors

[![koriym](https://avatars.githubusercontent.com/u/529021?v=4)](https://github.com/koriym "koriym (155 commits)")[![NaokiTsuchiya](https://avatars.githubusercontent.com/u/17171732?v=4)](https://github.com/NaokiTsuchiya "NaokiTsuchiya (12 commits)")[![apple-x-co](https://avatars.githubusercontent.com/u/8497012?v=4)](https://github.com/apple-x-co "apple-x-co (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ray-psr-cache-module/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[bear/package

BEAR.Sunday application framework package

30527.9k23](/packages/bear-package)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[neos/cache

Neos Cache Framework

102.0M31](/packages/neos-cache)

PHPackages © 2026

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