PHPackages                             thecodingmachine/stash-universal-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. thecodingmachine/stash-universal-module

ActiveLibrary[Caching](/categories/caching)

thecodingmachine/stash-universal-module
=======================================

Cross-framework module for Stash

v1.1.0(8y ago)0110.5k11MITPHPPHP &gt;=7.0

Since Sep 22Pushed 8y ago6 watchersCompare

[ Source](https://github.com/thecodingmachine/stash-universal-module)[ Packagist](https://packagist.org/packages/thecodingmachine/stash-universal-module)[ RSS](/packages/thecodingmachine-stash-universal-module/feed)WikiDiscussions 1.1 Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (4)Used By (1)

[![Build Status](https://camo.githubusercontent.com/42dcb6aea2d795bd638566f36e2146a5969839639aa866badcc305e102bc8fd1/68747470733a2f2f7472617669732d63692e6f72672f746865636f64696e676d616368696e652f73746173682d756e6976657273616c2d6d6f64756c652e7376673f6272616e63683d312e30)](https://travis-ci.org/thecodingmachine/stash-universal-module)[![Coverage Status](https://camo.githubusercontent.com/b9010328948f7ebda8db64743b4e16511e54b2b53be23f2e9964f8c6c9b99d8f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f746865636f64696e676d616368696e652f73746173682d756e6976657273616c2d6d6f64756c652f62616467652e7376673f6272616e63683d312e3026736572766963653d676974687562)](https://coveralls.io/github/thecodingmachine/stash-universal-module?branch=1.0)

Stash universal module
======================

[](#stash-universal-module)

This package integrates Stash (the PHP PSR-6 compatible cache library) in any [container-interop/service-provider](https://github.com/container-interop/service-provider) compatible framework/container.

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

[](#installation)

```
composer require thecodingmachine/stash-universal-module

```

Once installed, you need to register the [`TheCodingMachine\StashServiceProvider`](src/StashServiceProvider.php) into your container.

If your container supports thecodingmachine/discovery integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register *service providers*.

Introduction
------------

[](#introduction)

This service provider is meant to create a PSR-6 cache pool `Psr\Cache\CacheItemPoolInterface` instance.

Out of the box, the instance should be usable with sensible defaults. We tried to keep the defaults usable for most of the developer, while still providing best performances for the server.

### Usage

[](#usage)

```
use Psr\Cache\CacheItemPoolInterface

$cachePool = $container->get(CacheItemPoolInterface::class);
echo $cachePool->getItem('my_cached_value')->get();
```

### Default values

[](#default-values)

By default:

- The default cache pool is a composite pool made of:
    - An ephemeral (in-memory) driver for fast access to already fetched values
    - An APC driver (or a Filesystem driver as fallback if APC is not available)

Configuration
-------------

[](#configuration)

**Important**: This service provider accepts an optional parameter in the constructor: a "suffix" that can be used if you want many different instances.

```
use Psr\Cache\CacheItemPoolInterface

// Let's assume we are using Simplex as our container
$container = new Simplex\Container();
// Registers a default service provider
$container->register(new StashServiceProvider());
// Registers another service provider for a shared memcache pool
$container->register(new StashServiceProvider('shared'));

// Lets configure the second service provider.
$container['stash.shared.memcache.options'] = [
    'servers' => ['127.0.0.1', '11211']
];
// Let's override the composite options to put an ephemeral driver and the memcache driver next.
$container['stash.composite.options'] = function(ContainerInterface $container) {
    return [
        $container->get(Ephemeral::class),
        $container->get(Memcache::class)
    ];
}

$defaultCachePool = $container->get(CacheItemPoolInterface::class);
//... do stuff with the default pool

// The shared memcache pool can be accessed by suffixing the instance with ".shared".
$sharedCachePool = $container->get(CacheItemPoolInterface::class.'.shared');
//... do stuff
```

When this service provider looks for a service, it will first look for the service prefixed with the package name, then for the service directly. So if this documentation states that the `stash.apc.options` entry is used, the service provider will first look into `thecodingmachine.stash-universal-module.stash.apc.options` and then into `stash.apc.options`. This allows you to keep your container clean (with only one `stash.apc.options` entry), and in case there are several service providers using that `stash.apc.options` entry and you want to pass different values, you can still edit `thecodingmachine.stash-universal-module.stash.apc.options` for this service provider only.

Expected values / services
--------------------------

[](#expected-values--services)

This *service provider* expects the following configuration / services to be available:

NameCompulsoryDescription`stash.apc.options` (or `stash.[suffix].apc.options`)*no*The set of options passed to the APC driver. Defaults to `[]`.`stash.filesystem.options` (or `stash.[suffix].filesystem.options`)*no*The set of options passed to the Filesystem driver. Defaults to `[]`.`stash.memcache.options` (or `stash.[suffix].memcache.options`)*no* (unless you want to use the Memcache driver)The [set of options](http://www.stashphp.com/Drivers.html#memcached) passed to the Memcache driver.`stash.redis.options` (or `stash.[suffix].redis.options`)*no* (unless you want to use the Redis driver)The [set of options](http://www.stashphp.com/Drivers.html#memcached) passed to the Redis driver.`stash.sqlite.options` (or `stash.[suffix].sqlite.options`)*no*The set of options passed to the SQLite driver. Defaults to `[]`.Provided services
-----------------

[](#provided-services)

This *service provider* provides the following services:

Service nameDescription`CacheItemPoolInterface::class` (or `CacheItemPoolInterface::class.[suffix]`)An alias to `Pool::class`.`Pool::class` (or `Pool::class.[suffix]`)The default Stash pool. Uses the `DriverInterface::class` default driver.`PoolInterface::class` (or `PoolInterface::class.[suffix]`)An alias to `Pool::class`.`DriverInterface::class` (or `DriverInterface::class.[suffix]`)The default Stash driver to be used. By default, it is a Composite driver (see below)`Composite::class` (or `Composite::class.[suffix]`)The Composite driver. It composes several drivers, specified in the 'stash.composite.options' list`stash.composite.options` (or `stash.[suffix].composite.options`)The options that will be passed to the composite driver. By default, this is a list of drivers, with the Ephemeral driver being the first one, and then APC (if available) or FileSystem (if APC is not available)`Apc::class` (or `Apc::class.[suffix]`)The APC driver.`FileSystem::class` (or `FileSystem::class.[suffix]`)The Filesystem driver.`Ephemeral::class` (or `Ephemeral::class.[suffix]`)The Ephemeral driver.`BlackHole::class` (or `BlackHole::class.[suffix]`)The BlackHole driver.`Memcache::class` (or `Memcache::class.[suffix]`)The Memcache driver.`Redis::class` (or `Redis::class.[suffix]`)The Redis driver.`Sqlite::class` (or `Sqlite::class.[suffix]`)The Sqlite driver.Extended services
-----------------

[](#extended-services)

This *service provider* does not extend any service.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~1 days

Total

4

Last Release

3157d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thecodingmachine-stash-universal-module/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-stash-universal-module/health.svg)](https://phpackages.com/packages/thecodingmachine-stash-universal-module)
```

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[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)[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

841.4M16](/packages/tedivm-stash-bundle)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)[elcobvg/laravel-opcache

Custom OPcache Cache Driver for Laravel. Faster than Redis or memcached.

43317.1k1](/packages/elcobvg-laravel-opcache)

PHPackages © 2026

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