PHPackages                             tedivm/stash - 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. tedivm/stash

ActiveLibrary[Caching](/categories/caching)

tedivm/stash
============

The place to keep your cache.

v1.2.2(4mo ago)9824.8M↓11.3%131[34 issues](https://github.com/tedious/Stash/issues)20BSD-3-ClausePHPPHP ^8.0CI passing

Since Mar 9Pushed 4mo ago27 watchersCompare

[ Source](https://github.com/tedious/Stash)[ Packagist](https://packagist.org/packages/tedivm/stash)[ Docs](http://github.com/tedious/Stash)[ GitHub Sponsors](https://github.com/tedivm)[ Fund](https://tidelift.com/funding/github/packagist/tedivm/stash)[ RSS](/packages/tedivm-stash/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (40)Used By (20)

Stash - A PHP Caching Library
=============================

[](#stash---a-php-caching-library)

[![License](https://camo.githubusercontent.com/85a956c28c2082c989dd357697e0e26188ea940f63db90848fb8d36d9b678350/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74656469766d2f73746173682e737667)](https://github.com/tedious/Stash/blob/master/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/8905cae8d82c2609c847662bfc1721da98713ae1d9b3be7f0f6b2572be72a816/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f746564696f75732f73746173682e737667)](https://packagist.org/packages/tedivm/stash)[![Total Downloads](https://camo.githubusercontent.com/0fcb203e60f224c486ff6955f384968e1067286b9a0bc8684e68d382df37b534/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74656469766d2f73746173682e737667)](https://packagist.org/packages/tedivm/stash)

Stash makes it easy to speed up your code by caching the results of expensive functions or code. Certain actions, like database queries or calls to external APIs, take a lot of time to run but tend to have the same results over short periods of time. This makes it much more efficient to store the results and call them back up later.

Installing
----------

[](#installing)

Installing Stash can be done through a variety of methods, although Composer is recommended.

### Composer

[](#composer)

Until Stash reaches a stable API with version 1.0 it is recommended that you review changes before Minor updates, although bug fixes will always be backwards compatible.

```
"require": {
  "tedivm/stash": "0.17.*"
}
```

or by using the `composer require` command:

```
composer require tedivm/stash

```

### Github

[](#github)

Releases of Stash are available on [Github](https://github.com/tedious/Stash/releases).

Documentation
-------------

[](#documentation)

Although this README contains some useful data there is a lot more information at the main site, [stashphp.com](http://www.stashphp.com/).

Core Concepts
-------------

[](#core-concepts)

### Main Classes

[](#main-classes)

Stash has three main components: a `Pool` class that represents a specific grouping of cached objects, an `Item` class that provides access to individual objects, and a series of `Driver` classes that allow Stash to interact with caching systems.

Each `Driver` is initialized and then passed into a `Pool`, at which point the developer can simply forget about it. Developers also have the option of using multiple Drivers together by joining them with the Composite Driver.

The `Pool` class allows developers to perform a number of tasks. There are a few maintenance related tasks, such as running a "Purge" to allow backend systems to perform maintenance tasks or set new logging or driver classes. The `Pool` also can be used to create `Item` objects, singly or in groups.

Each `Item` represents a single object inside the cache. It has a unique Key, meaning that any two Items created from the same `Pool` will contain the same Value. An `Item` can set, get and remove a value from a caching system.

### Keys

[](#keys)

A Key is a string that represents an Item in a caching system. At its simplest, a key is an alphanumeric string and has a one to one relationship with a value in the cache.

Stash provides a feature known as "stacks" that allows developers to group related Items together so they can be erased as a group. This is done by giving Items a nested structure, similar to folders on a computer. Just like with folders, this is represented by adding slashes to the name representing the file or cached object.

For example, a Key like "/models/users/34/profile" can allow developers to clear the data for specific users using that user's id, or clear the data for all users or even all models. It can also allow that developer to break up data into specific pieces to only load what is needed.

### Session Storage

[](#session-storage)

The provided Session class takes a Pool in its constructor and can then be registered as a Session Handler using the built-in PHP methods, the Session::registerHandler static function, or by using any framework that uses the SessionHandlerInterface interface.

Drivers
-------

[](#drivers)

Stash currently supports the following backends:

- FileSystem
- Sqlite
- APC
- Memcached
- Redis
- Ephemeral (runtime only)

Stash also supports a specialized "Composite" Driver which can contain any number of the above drivers. This allows developers to created multi-tiered drivers that use a variety of back ends.

Symfony Integration
-------------------

[](#symfony-integration)

The [Stash Bundle](https://github.com/tedious/TedivmStashBundle) makes using Stash inside of Symfony projects significantly easier. This bundle exposes Stash as a Service for developers to use, and allows Symfony to use Stash as a session handler.

License
-------

[](#license)

Stash is licensed under the BSD License. See the LICENSE file for details.

Reporting Security and Vulnerability Issues
-------------------------------------------

[](#reporting-security-and-vulnerability-issues)

This project utilizes the [Tidelift Security Reporting System](https://tidelift.com/security) for security and vulnerability reporting.

Support
-------

[](#support)

Issues can be opened directly in Github for issues that aren't related to security.

[Professionally supported Stash is now available with Tidelift.](https://tidelift.com/subscription/pkg/packagist-tedivm-stash?utm_source=packagist-tedivm-stash&utm_medium=referral&utm_campaign=readme)

###  Health Score

70

—

ExcellentBetter than 100% of packages

Maintenance74

Regular maintenance activity

Popularity67

Solid adoption and visibility

Community51

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.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 ~148 days

Recently: every ~174 days

Total

35

Last Release

142d ago

Major Versions

v0.18.0 → v1.0.02024-01-30

PHP version history (6 changes)v0.9.5PHP &gt;=5.3.0

v0.13.1PHP &gt;=5.4.0

v0.13.2PHP ^5.4|^7.0

v0.15.1PHP ^7.0

v0.16.0PHP &gt;7.0

v0.18.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4073e6f375aee032560ba55fb85743cb5f49a1e46b88cf4360f745239e5ec9e6?d=identicon)[tedivm](/maintainers/tedivm)

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

---

Top Contributors

[![tedivm](https://avatars.githubusercontent.com/u/121709?v=4)](https://github.com/tedivm "tedivm (665 commits)")[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (32 commits)")[![jhallbachner](https://avatars.githubusercontent.com/u/910695?v=4)](https://github.com/jhallbachner "jhallbachner (27 commits)")[![davereid](https://avatars.githubusercontent.com/u/62967?v=4)](https://github.com/davereid "davereid (13 commits)")[![iclukas](https://avatars.githubusercontent.com/u/1122393?v=4)](https://github.com/iclukas "iclukas (8 commits)")[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (6 commits)")[![pwhelan](https://avatars.githubusercontent.com/u/601645?v=4)](https://github.com/pwhelan "pwhelan (5 commits)")[![jonmchan](https://avatars.githubusercontent.com/u/1827190?v=4)](https://github.com/jonmchan "jonmchan (5 commits)")[![CMCDragonkai](https://avatars.githubusercontent.com/u/640797?v=4)](https://github.com/CMCDragonkai "CMCDragonkai (5 commits)")[![Finesse](https://avatars.githubusercontent.com/u/9006227?v=4)](https://github.com/Finesse "Finesse (5 commits)")[![DavidGoodwin](https://avatars.githubusercontent.com/u/203929?v=4)](https://github.com/DavidGoodwin "DavidGoodwin (4 commits)")[![mrclay](https://avatars.githubusercontent.com/u/170687?v=4)](https://github.com/mrclay "mrclay (4 commits)")[![alexbowers](https://avatars.githubusercontent.com/u/842974?v=4)](https://github.com/alexbowers "alexbowers (3 commits)")[![andrerom](https://avatars.githubusercontent.com/u/289757?v=4)](https://github.com/andrerom "andrerom (3 commits)")[![icio](https://avatars.githubusercontent.com/u/408401?v=4)](https://github.com/icio "icio (3 commits)")[![KorvinSzanto](https://avatars.githubusercontent.com/u/1007419?v=4)](https://github.com/KorvinSzanto "KorvinSzanto (3 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (3 commits)")[![thesebas](https://avatars.githubusercontent.com/u/827416?v=4)](https://github.com/thesebas "thesebas (3 commits)")[![lolautruche](https://avatars.githubusercontent.com/u/313528?v=4)](https://github.com/lolautruche "lolautruche (2 commits)")[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (2 commits)")

---

Tags

cachingphprediscachecachingpsr6psr-6memcachedapcsessions

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/tedivm-stash/health.svg)

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

###  Alternatives

[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

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

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[matthiasmullie/scrapbook

Scrapbook is a PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APCu, SQL and additional capabilities (e.g. transactions, stampede protection) built on top.

3212.5M32](/packages/matthiasmullie-scrapbook)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[jamm/memory

Key-value storage in memory. As a storage can be used: APC, Redis, Memcache, Shared memory. All storage objects have one interface, so you can switch them without changing the working code. Contains PHP Redis client.

13326.3k1](/packages/jamm-memory)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.1k](/packages/ihor-cachalot)

PHPackages © 2026

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