PHPackages                             dan/laravel-cached - 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. dan/laravel-cached

ActiveProject[Caching](/categories/caching)

dan/laravel-cached
==================

Your Laravel models, decorated, cached, and pleasantly accessible.

v0.1.0(4y ago)041.3k↓93.3%1MITPHPPHP &gt;=7.1

Since Dec 18Pushed 2y ago3 watchersCompare

[ Source](https://github.com/danrichards/laravel-cached)[ Packagist](https://packagist.org/packages/dan/laravel-cached)[ RSS](/packages/dan-laravel-cached/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (4)Versions (26)Used By (0)

Cached (More for Laravel)
=========================

[](#cached-more-for-laravel)

A cache decorator that feels like **more** Laravel.

Highlights
----------

[](#highlights)

### Usage with helper

[](#usage-with-helper)

> Examples

```
// Fetch a model from the cache
$user = cached(User::class, 1);                 // App\User

// The default decorated class or
// CACHE_DECORATOR specified on model.
$u = cached(User::class, 1, $decorate = true)   // More\Laravel\Cached\CacheDecorator

// A specific decorator to be returned
$u = cached(User::class, 1, Dashboard::class);  // App\Presenters\Dashboard

// A specific decorator to be returned
$u = cachedOrFail(User::class, 200000, Dashboard::class);  // throws ModelNotFoundException

```

### Usage with the macro

[](#usage-with-the-macro)

> Examples

```
// Find a model from the cache / db
$user = User::cached($id = 1);                  // App\User

// Find or fail from the cache /db
$user = User::cachedOrFail($id = 200000);       // throws ModelNotFoundException

// Fail with exception or decorate.
$u = User::cachedOrFail($id = 1)->decorate()    // More\Laravel\Cached\CacheDecorator

// Param can be used when model may not be found
$u = User::cached($id = 1, $decorate = true)    // More\Laravel\Cached\CacheDecorator

// A specific decorator to be returned
$u = User::cachedOrFail($id = 1)                // App\Presenters\Dashboard
    ->decorate(Dashboard::class);

// A specific decorator to be returned
$u = User::cached($id = 1, Dashboard::class);   // App\Presenters\Dashboard

```

More on Decorators
------------------

[](#more-on-decorators)

> A basic `CacheDecorator` is included by default. But you can publish the config to switch the global default.

### Default `CacheDecorator`

[](#default-cachedecorator)

```
$ php artisan vendor:publish --provider="\More\Laravel\Cached\Support\CachedServiceProvider"

```

### Model constant `CACHE_DECORATOR`

[](#model-constant-cache_decorator)

> If your decorator demands various cached methods for your model, you can override the global behavior on each model as well.

```
class User extends Model
{
    const CACHE_DECORATOR = \App\Metrics\UserMetrics::class;
}

---

$user->decorate();                              // \App\Metrics\UserMetrics

```

### Decorated on run-time

[](#decorated-on-run-time)

> As you've already seen in the examples at the top, you can specify a decorator you want back at run-time.

Suggestions
-----------

[](#suggestions)

This pattern plays very nice with `hemp/presenter`. Just extend his `Presenter` class, add the trait included, and overload construct.

Additionally, a overloading route-model binding with a drop-in replacement would be cool.

More testing and discovery with nested cache forgetting, and cache pre-warming.

Composer
--------

[](#composer)

```
$ composer require dan/laravel-cached dev-master

```

Contributors
------------

[](#contributors)

- [Diogo Gomes](https://github.com/diogogomeswww)

License
-------

[](#license)

MIT.

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64% 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 ~54 days

Recently: every ~207 days

Total

23

Last Release

1615d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.6

v0.0.11PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/058e584a67bb904f19799d08a3609de0af4de77e989d50bcdb27f66f0ecfba14?d=identicon)[danrichards](/maintainers/danrichards)

![](https://avatars.githubusercontent.com/u/219?v=4)[Dan Benjamin](/maintainers/dan)[@dan](https://github.com/dan)

---

Top Contributors

[![diogogomeswww](https://avatars.githubusercontent.com/u/11543163?v=4)](https://github.com/diogogomeswww "diogogomeswww (16 commits)")[![danrichards](https://avatars.githubusercontent.com/u/470255?v=4)](https://github.com/danrichards "danrichards (8 commits)")[![colepizzarella](https://avatars.githubusercontent.com/u/10200684?v=4)](https://github.com/colepizzarella "colepizzarella (1 commits)")

---

Tags

laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dan-laravel-cached/health.svg)

```
[![Health](https://phpackages.com/badges/dan-laravel-cached/health.svg)](https://phpackages.com/packages/dan-laravel-cached)
```

###  Alternatives

[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M110](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)[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.

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

PHPackages © 2026

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