PHPackages                             onnerby/nestedcache - 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. onnerby/nestedcache

ActiveLibrary[Caching](/categories/caching)

onnerby/nestedcache
===================

A nested cache that can be invalidated through relations and/or hierarchy

1.0.1(6y ago)04[1 PRs](https://github.com/onnerby/nestedcache/pulls)MITPHP

Since Feb 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/onnerby/nestedcache)[ Packagist](https://packagist.org/packages/onnerby/nestedcache)[ Docs](https://github.com/onnerby/nestedcache)[ RSS](/packages/onnerby-nestedcache/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

NestedCache
===========

[](#nestedcache)

A nested cache that can be invalidated through relations and/or hierarchy

Lets start with an simple example:

```
\Doe\NestedCache::init();

if ($cache = \Doe\NestedCache::get(['book-gallery'])) {
	// Do stuff with book gallery cache
} else {
	\Doe\NestedCache::start(['book-gallery']);
	$newCache = 'Lots of generated data';
	...
	\Doe\NestedCache::end($newCache);
}

// Remove the cache
\Doe\NestedCache::invalidate(['book-gallery']);
```

How about nesting?
------------------

[](#how-about-nesting)

Let's try nesting our book gallery by caching books inside

```
\Doe\NestedCache::init();

if ($cache = \Doe\NestedCache::get(['book-gallery'])) {
	// Do stuff with book gallery cache
} else {
	\Doe\NestedCache::start(['book-gallery']);
	$newCache = "";
	foreach ($books as $book) {
		if (!($bookOutput = \Doe\NestedCache::get(['book-listing', $book->id]))) {
			$bookOutput = "book: " . $book->name . "\n";
			\Doe\NestedCache::set(['book-listing', $book->id], $bookOutput);
		}
		$newCache .= $bookOutput;
	}

	\Doe\NestedCache::end($newCache);
}

// Remove the cache for a single book will also remove cache for "book-gallery" (but not for other book listings)
\Doe\NestedCache::invalidate(['book-listing', 123]);
```

Engines
-------

[](#engines)

There are so far only 2 options.

- APCu: (default) `\Doe\NestedCache::init(['engine' => 'APCu']);`
- TempMemory: A in memory cache only for current request (mostly for debug purpose) `\Doe\NestedCache::init(['engine' => 'TempMemory']);`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

2294d ago

### Community

Maintainers

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

---

Top Contributors

[![onnerby](https://avatars.githubusercontent.com/u/1788794?v=4)](https://github.com/onnerby "onnerby (3 commits)")

---

Tags

phpcache

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/onnerby-nestedcache/health.svg)

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

###  Alternatives

[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[eftec/cacheone

A Cache library with minimum dependency

103.5k4](/packages/eftec-cacheone)

PHPackages © 2026

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