PHPackages                             duncan3dc/cache - 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. duncan3dc/cache

ActiveLibrary[Caching](/categories/caching)

duncan3dc/cache
===============

Simple PSR-6/PSR-16 compatible disk cache

2.0.0(1y ago)871.8k↓50%24Apache-2.0PHPPHP ^8.0CI passing

Since Mar 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/duncan3dc/cache)[ Packagist](https://packagist.org/packages/duncan3dc/cache)[ Docs](https://github.com/duncan3dc/cache)[ RSS](/packages/duncan3dc-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (11)Used By (4)

cache
=====

[](#cache)

A simple [PSR-6](http://www.php-fig.org/psr/psr-6/)/[PSR-16](http://www.php-fig.org/psr/psr-16/) compatible disk cache for PHP

[![release](https://camo.githubusercontent.com/a0c1c795b9657ff8c4ccd5d546a57ad780402cda77f776f3c7e998f64eea01ec/68747470733a2f2f706f7365722e707567782e6f72672f64756e63616e3364632f63616368652f76657273696f6e2e737667)](https://packagist.org/packages/duncan3dc/cache)[![build](https://github.com/duncan3dc/cache/workflows/.github/workflows/buildcheck.yml/badge.svg?branch=main)](https://github.com/duncan3dc/cache/actions?query=branch%3Amain+workflow%3A.github%2Fworkflows%2Fbuildcheck.yml)[![coverage](https://camo.githubusercontent.com/59296219ef04c03f7fda635d62f2121b88b5769bb4b5cf46e393f9c29ce17120/68747470733a2f2f636f6465636f762e696f2f67682f64756e63616e3364632f63616368652f67726170682f62616467652e737667)](https://codecov.io/gh/duncan3dc/cache)

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

[](#installation)

The recommended method of installing this library is via [Composer](//getcomposer.org/).

Run the following command from your project root:

```
$ composer require duncan3dc/cache
```

Quick Examples
--------------

[](#quick-examples)

There are 2 cache providers available, one is the local filesystem and the other is simple array cache in memory.

Using the `FilesystemPool` will persist data forever (or until the filesystem is purged).

```
$cache = new \duncan3dc\Cache\FilesystemPool(sys_get_temp_dir());

# The $cache object implements PSR-6
$userData = $cache->getItem("user_data")->get();

# ...and PSR-16
$userData = $cache->get("user_data");
```

Using the `ArrayPool` will not persist data beyond the current request.

```
$cache = new \duncan3dc\Cache\ArrayPool();

# The $cache object implements PSR-6
$userData = $cache->getItem("user_data")->get();

# ...and PSR-16
$userData = $cache->get("user_data");
```

There's also a trait to allow any method to be automatically cached.

```
$cache = new class {
    use \duncan3dc\Cache\CacheCallsTrait;

    public function _getData()
    {
        return [];
    }
};

$cache->getData();
```

The first time `getData()` is called then `_getData()` will be run, but after that future calls to `getData()` will just return the cached result from the first call to `_getData()`.

Changelog
---------

[](#changelog)

A [Changelog](CHANGELOG.md) has been available since the beginning of time

Where to get help
-----------------

[](#where-to-get-help)

Found a bug? Got a question? Just not sure how something works?
Please [create an issue](//github.com/duncan3dc/cache/issues) and I'll do my best to help out.
Alternatively you can catch me on [Twitter](https://twitter.com/duncan3dc)

duncan3dc/cache for enterprise
------------------------------

[](#duncan3dccache-for-enterprise)

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/cache and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-duncan3dc-cache?utm_source=packagist-duncan3dc-cache&utm_medium=referral&utm_campaign=readme)

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% 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 ~354 days

Recently: every ~598 days

Total

9

Last Release

516d ago

Major Versions

0.6.1 → 1.0.02022-03-13

1.0.0 → 2.0.02024-12-18

PHP version history (5 changes)0.1.0PHP ^5.6|^7.0

0.5.0PHP ^7.0

0.6.0PHP ^7.1

1.0.0PHP ^7.3 || ^8.0

2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/11dc66042513f11d1c99b1e6763f25dca84a3ff31cdbea3972b9b804a3d3d5e9?d=identicon)[duncan3dc](/maintainers/duncan3dc)

---

Top Contributors

[![duncan3dc](https://avatars.githubusercontent.com/u/546811?v=4)](https://github.com/duncan3dc "duncan3dc (72 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

cachephppsr-16psr-6arraycachesimple-cachepsr-16memorypsr6psr-6diskpsr16

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/duncan3dc-cache/health.svg)

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

###  Alternatives

[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)[cache/array-adapter

A PSR-6 cache implementation using a php array. This implementation supports tags

548.3M151](/packages/cache-array-adapter)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

423.1M27](/packages/cache-simple-cache-bridge)[codeigniter4/cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

1320.1k](/packages/codeigniter4-cache)

PHPackages © 2026

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