PHPackages                             devcuongnguyen/laravel-caching-model - 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. devcuongnguyen/laravel-caching-model

ActiveLibrary[Caching](/categories/caching)

devcuongnguyen/laravel-caching-model
====================================

A simple cache library for laravel eloquent model

1.0.1(1y ago)0561MITPHPPHP ^7.0|^8.0

Since Jan 9Pushed 1y agoCompare

[ Source](https://github.com/devcuongnguyen/laravel-caching-model)[ Packagist](https://packagist.org/packages/devcuongnguyen/laravel-caching-model)[ RSS](/packages/devcuongnguyen-laravel-caching-model/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (1)

laravel-caching-model
=====================

[](#laravel-caching-model)

- Simple package for caching laravel eloquent model
- Support retrieve model stored in cache store by id (or other primary key)

Usage
=====

[](#usage)

1. Implement Cacheable interface then use HasCache trait:

```
use devcuongnguyen\CachingModel\Contracts\Cacheable;
use devcuongnguyen\CachingModel\HasCache;

class Setting extends Model implements Cacheable
{
    use HasCache;

    ...
}
```

2. use `fromCache()` static method to retrieve model data from cache storage

```
$cachedInstance = Setting::fromCache()->find($key);
```

Available methods:
==================

[](#available-methods)

1. public static function primaryCacheKey(): string;

- Return primary key for creating cache key
- Default: id

2. public static function getCacheKey($id): string;

- Return cache key for specific instance with primary key is $id

3. public static function cacheTimeout(): int;

- Return cache timeout

4. public function scopeCacheWithRelation($query);

- Specific relationship will cache together model

```
public function scopeCacheWithRelation($query)
{
    return $query->with('relationship:id);
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance42

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~376 days

Total

2

Last Release

478d ago

### Community

Maintainers

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

---

Top Contributors

[![devcuongnguyen](https://avatars.githubusercontent.com/u/152869938?v=4)](https://github.com/devcuongnguyen "devcuongnguyen (2 commits)")[![hacoidev](https://avatars.githubusercontent.com/u/108921745?v=4)](https://github.com/hacoidev "hacoidev (2 commits)")

### Embed Badge

![Health badge](/badges/devcuongnguyen-laravel-caching-model/health.svg)

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

###  Alternatives

[imanghafoori/laravel-widgetize

A minimal yet powerful package to give a better structure and caching opportunity for your Laravel apps.

909137.9k12](/packages/imanghafoori-laravel-widgetize)[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)[alexmg86/laravel-sub-query

Laravel subquery

7538.4k](/packages/alexmg86-laravel-sub-query)[laravel-enso/rememberable

Model caching dependency for Laravel Enso

2863.2k25](/packages/laravel-enso-rememberable)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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