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

ActiveLibrary[Caching](/categories/caching)

darrynten/any-cache
===================

Adapter designed to add Framework Agnosticism for Caching within PHP Packages.

v1.0.1(9y ago)880.2k↓100%2[6 PRs](https://github.com/darrynten/any-cache/pulls)2MITPHPPHP ^5.5.9 || ^7.0

Since Feb 9Pushed 5y ago2 watchersCompare

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

READMEChangelog (2)Dependencies (8)Versions (8)Used By (2)

any-cache
---------

[](#any-cache)

[![Travis Build Status](https://camo.githubusercontent.com/99fa69311e465c1074641ec73d4f1e46124a3793d07f86f56a60bcb5eef639ec/68747470733a2f2f7472617669732d63692e6f72672f64617272796e74656e2f616e792d63616368652e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/99fa69311e465c1074641ec73d4f1e46124a3793d07f86f56a60bcb5eef639ec/68747470733a2f2f7472617669732d63692e6f72672f64617272796e74656e2f616e792d63616368652e7376673f6272616e63683d6d6173746572)[![StyleCI Status](https://camo.githubusercontent.com/ae681a39025144ed1ef894a3fa86e1b9db2a9be7b42f6371003cf39c6bc013ab/68747470733a2f2f7374796c6563692e696f2f7265706f732f38303932333939312f736869656c643f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/ae681a39025144ed1ef894a3fa86e1b9db2a9be7b42f6371003cf39c6bc013ab/68747470733a2f2f7374796c6563692e696f2f7265706f732f38303932333939312f736869656c643f6272616e63683d6d6173746572)[![codecov](https://camo.githubusercontent.com/0340c070b74fd9292494e5dd16ae1705c7ff816f94c78253e9f48225b3afb314/68747470733a2f2f636f6465636f762e696f2f67682f64617272796e74656e2f616e792d63616368652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/darrynten/any-cache)[![Packagist Version](https://camo.githubusercontent.com/b0da9c51781fc83ec836043faec68ec7ad83ce9eb2ec18a7004cf2d46d997c46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617272796e74656e2f616e792d63616368652e737667)](https://camo.githubusercontent.com/b0da9c51781fc83ec836043faec68ec7ad83ce9eb2ec18a7004cf2d46d997c46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617272796e74656e2f616e792d63616368652e737667)[![MIT License](https://camo.githubusercontent.com/8e71abee720f563ca9411e4946f263a6ed3590b70b0a960ec9a40594b711185c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64617272796e74656e2f616e792d63616368652e737667)](https://camo.githubusercontent.com/8e71abee720f563ca9411e4946f263a6ed3590b70b0a960ec9a40594b711185c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64617272796e74656e2f616e792d63616368652e737667)

Adapter designed to add Framework Agnosticism for Caching within PHP Packages.

Supports PHP 5.6+

### Install

[](#install)

```
composer require darrynten/any-cache
```

### Goal

[](#goal)

Allow package developers to use whichever caching mechanisms are native to whichever framework it is installed in via a simple interface.

Can be passed an artifact, but can also autodetect its host framework.

Passing in takes precedence and allows developers to use a specific framework but with a totally different cache library or configuration.

### Details

[](#details)

Package creators can include `AnyCache` in their packages and leverage supported host framework native caching capabilities.

`AnyCache` auto-detects its host framework and does not require any extra configuration, although it also allows passing in a desired cache.

If none is provided or if there is no caching available, then a local temporary `ArrayCache` is created and will be used by default. This is transient and not persistent.

This allows you to not have any additional caching requirements in your packages while allowing you to leverage whichever caching constructs are already in place.

### Supported Frameworks

[](#supported-frameworks)

- Temporary Array (default)
- Laravel
- Symfony
- Doctrine
- Psr6
- CodeIgniter (partially complete)
- ...

### Supported Cache Calls

[](#supported-cache-calls)

- get ($key, $default)
- set ($key, $value, $time)
- has ($key)
- pull ($key)
- forever ($key, $value)
- ...

### Provides

[](#provides)

Create a new instance.

```
use DarrynTen\AnyCache;

$this->cache = new AnyCache()
```

Call

```
$key = 'foo';
$value = 'bar';
$time = 60;

// Set a value
$this->cache()->set($key, $value, $time);

// Get a cached value
$result = $this->cache()->get($key);

// Check if a key exists
if ($this->cache->has($key)) {
  //
}

// Get and unset
$result = $this->cache()->pull($key);
```

### Notes

[](#notes)

The CodeIgniter support is not complete, and it does not auto-detect this framework at this time.

### Missing Tests

[](#missing-tests)

The Laravel tests are not 100% complete, there is an issue with testing the Cache Facade on the `get` method.

The factory does not have unit test coverage at this point in time.

The main class is also not tested yet.

#### Acknowledgments

[](#acknowledgments)

- [Marcel Pociot](https://github.com/mpociot) and his [Botman Project](https://github.com/mpociot/botman)for the original idea and implementation.
- [Alexander Marinov](https://github.com/ssaki) for his amazing skills.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

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

Total

2

Last Release

3376d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8458e77a1e51443980bc078f1df4954070d63d2f98b6174adfb6ce035a05e63f?d=identicon)[darrynten](/maintainers/darrynten)

---

Top Contributors

[![darrynten](https://avatars.githubusercontent.com/u/3657251?v=4)](https://github.com/darrynten "darrynten (45 commits)")

---

Tags

adapteragnostic-implementationagnostic-to-frameworkscachingphpcacheadapterframework agnostic

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[psr/cache

Common interface for caching libraries

5.2k686.9M1.3k](/packages/psr-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[madewithlove/illuminate-psr-cache-bridge

861.5M13](/packages/madewithlove-illuminate-psr-cache-bridge)[beste/in-memory-cache

A PSR-6 In-Memory cache that can be used as a fallback implementation and/or in tests.

2512.2M6](/packages/beste-in-memory-cache)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33313.0k](/packages/anahkiasen-flatten)

PHPackages © 2026

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