PHPackages                             craftcms/laravel-dependency-aware-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. craftcms/laravel-dependency-aware-cache

ActiveLibrary[Caching](/categories/caching)

craftcms/laravel-dependency-aware-cache
=======================================

A dependency aware cache repository for Laravel

1.2.3(2mo ago)235.1k↓13%BSD-3-ClausePHPPHP ^8.2CI passing

Since Jul 17Pushed 2mo agoCompare

[ Source](https://github.com/craftcms/laravel-dependency-aware-cache)[ Packagist](https://packagist.org/packages/craftcms/laravel-dependency-aware-cache)[ Docs](https://github.com/craftcms/laravel-dependency-aware-cache)[ RSS](/packages/craftcms-laravel-dependency-aware-cache/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (36)Versions (12)Used By (0)

Dependency-aware cache for Laravel
==================================

[](#dependency-aware-cache-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/93f9c91cc3449c37ca89dc0999fd2be11defa47fa555a8cd4f1f7720742bebdc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372616674636d732f6c61726176656c2d646570656e64656e63792d61776172652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/craftcms/laravel-dependency-aware-cache)[![GitHub Tests Action Status](https://camo.githubusercontent.com/496bd789f6be0c851f2bd0e6450138fa2eb40abfdb955812a991f7869a15bbb4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6372616674636d732f6c61726176656c2d646570656e64656e63792d61776172652d63616368652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/craftcms/laravel-dependency-aware-cache/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/1c03dfd35913c8dde1fa186f3bf7dfc60df9d9914fa33502d5fa0094ac63a70f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6372616674636d732f6c61726176656c2d646570656e64656e63792d61776172652d63616368652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/craftcms/laravel-dependency-aware-cache/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/dea597b4d49896b0f35feae680f913c3c8be6559358f4232223454d1d73d4bc1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6372616674636d732f6c61726176656c2d646570656e64656e63792d61776172652d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/craftcms/laravel-dependency-aware-cache)

An implementation of [Yii's cache with dependencies](https://github.com/yiisoft/cache) for Laravel

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

[](#installation)

You can install the package via composer:

```
composer require craftcms/laravel-dependency-aware-cache
```

Usage
-----

[](#usage)

The dependency aware repository is hooked up automatically and will be returned when using the `Cache` Facade.

This package also provides a `\CraftCms\DependencyAwareCache\Facades\DependencyCache` Facade which extends the default `Cache` Facade but provides updated docblocks.

```
use Illuminate\Support\Facades\Cache;
use CraftCms\DependencyAwareCache\DependencyAwareRepository;
use CraftCms\DependencyAwareCache\Facades\DependencyCache;

/** @var DependencyAwareRepository $cache */
$cache = Cache::store();

/** @var DependencyAwareRepository $cache */
$cache = DependencyCache::store();
```

### Invalidation

[](#invalidation)

When using the cache, you can specify a dependency that may trigger cache invalidation. Below is an example using the tag dependency:

```
use CraftCms\DependencyAwareCache\Dependency\TagDependency;
use Illuminate\Support\Facades\Cache;

Cache::put('item_42_price', 10, null, new TagDependency('item_42'));
Cache::put('item_42_total', 100, null, new TagDependency('item_42'));

Cache::get('item_42_price'); // 10
Cache::get('item_42_total'); // 100

TagDependency::invalidate('item_42');

Cache::get('item_42_price'); // null
Cache::get('item_42_total'); // null
```

Other dependencies:

- `CallbackDependency` - invalidates when the result of a callback changes.
- `FileDependency` - invalidates the cache based on file modification time.
- `ValueDependency` - invalidates the cache when specified value changes.
- You may combine multiple dependencies using `AnyDependency` or `AllDependencies`.

You can implement your own dependency by extending `Dependency`.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Pixel &amp; Tonic](https://github.com/craftcms)
- [Yii Software](https://www.yiiframework.com/)
- [All Contributors](../../contributors)

License
-------

[](#license)

Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance87

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

Recently: every ~37 days

Total

11

Last Release

63d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ccdf8b493035de2343c55bd889513e3af5c04d5823482a2b186ad16adb1c3e3?d=identicon)[brandonkelly](/maintainers/brandonkelly)

---

Top Contributors

[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (19 commits)")

---

Tags

laravelcachecraftcms

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/craftcms-laravel-dependency-aware-cache/health.svg)

```
[![Health](https://phpackages.com/badges/craftcms-laravel-dependency-aware-cache/health.svg)](https://phpackages.com/packages/craftcms-laravel-dependency-aware-cache)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M6](/packages/propaganistas-laravel-disposable-email)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21111.6k](/packages/iazaran-smart-cache)

PHPackages © 2026

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