PHPackages                             cklmercer/laravel-model-stash - 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. cklmercer/laravel-model-stash

ActiveLibrary[Caching](/categories/caching)

cklmercer/laravel-model-stash
=============================

Easily maintain a "forever" cache of your models.

v0.2.2(9y ago)324MITPHPPHP &gt;=5.6.4

Since Jul 21Pushed 9y agoCompare

[ Source](https://github.com/cklmercer/laravel-model-stash)[ Packagist](https://packagist.org/packages/cklmercer/laravel-model-stash)[ RSS](/packages/cklmercer-laravel-model-stash/feed)WikiDiscussions master Synced 4w ago

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

laravel-model-stash
===================

[](#laravel-model-stash)

Easily maintain a "forever" cache of your models.

*Disclaimer: This trait is best used on models which you rarely create, update or delete.*

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

[](#installation)

##### 1.) Install via composer

[](#1-install-via-composer)

```
composer require cklmercer/laravel-model-stash
```

Usage
-----

[](#usage)

##### 1.) Use the trait `Cklmercer\ModelStash\CacheForever` within your model.

[](#1-use-the-trait-cklmercermodelstashcacheforever-within-your-model)

```
// Role.php

use Cklmercer\ModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Models
{
    use CacheForever;

    // truncated for brevity..
}
```

Now, whenever you create/update/delete/restore an instance of your model your cache will automatically be updated.

##### 2.) Get an index of your cached models.

[](#2-get-an-index-of-your-cached-models)

*Note: The default cache name will be the plural form of your model's class name.*

```
$roles = \Cache::get('roles')
```

You can change your model's cache name by defining a `$cacheName` property on your model.

```
// Role.php

use Cklmercer\ModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    use CacheForever;

    /**
     * The model's cache name.
     *
     * @var string
     */
    protected $cacheName = 'cachedRoles';

    // truncated for brevity..
}
```

```
$roles = \Cache::get('cachedRoles');
```

##### 3.) Get a specific instance of a cached model.

[](#3-get-a-specific-instance-of-a-cached-model)

*Note: The convention used to get a specific instance is "cache-name:cache-key", with cache-key defaulting to your model's route key.*

```
$role = \Cache::get('roles:1')
```

You can change your model's cache key by defining a `$cacheKey` property on your model.

```
// Role.php

use Cklmercer\LaravelModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    use CacheForever;

    /**
     * The model's cache key.
     *
     * @var string
     */
     protected $cacheKey = 'slug';

     // truncated for brevity..
}
```

```
$role = \Cache::get('roles:admin')
```

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

4

Last Release

3627d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/55d01f80929176504b9112a744e7b7d360cc28b84f92a28565fe00bf86101c98?d=identicon)[cklmercer](/maintainers/cklmercer)

---

Top Contributors

[![cklmercer](https://avatars.githubusercontent.com/u/5618812?v=4)](https://github.com/cklmercer "cklmercer (12 commits)")

### Embed Badge

![Health badge](/badges/cklmercer-laravel-model-stash/health.svg)

```
[![Health](https://phpackages.com/badges/cklmercer-laravel-model-stash/health.svg)](https://phpackages.com/packages/cklmercer-laravel-model-stash)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[illuminate/cache

The Illuminate Cache package.

12937.0M1.7k](/packages/illuminate-cache)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M337](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k55.1k1](/packages/mike-bronner-laravel-model-caching)[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.

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

PHPackages © 2026

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