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

ActiveLibrary[Caching](/categories/caching)

tannhatcms/laravel-caching-model
================================

A simple cache library for laravel eloquent model

1.0.3(6mo ago)0956[1 PRs](https://github.com/TanNhatCMS/Laravel-Caching-Model/pulls)MITPHPPHP ^7.0|^8.0CI passing

Since Nov 18Pushed 1w agoCompare

[ Source](https://github.com/TanNhatCMS/Laravel-Caching-Model)[ Packagist](https://packagist.org/packages/tannhatcms/laravel-caching-model)[ RSS](/packages/tannhatcms-laravel-caching-model/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (6)Used By (0)

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 TanNhatCMS\CachingModel\Contracts\Cacheable;
use TanNhatCMS\CachingModel\Traits\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

41

—

FairBetter than 87% of packages

Maintenance84

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Total

4

Last Release

193d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/113796420?v=4)[KietNT](/maintainers/TanNhatCMS)[@TanNhatCMS](https://github.com/TanNhatCMS)

---

Top Contributors

[![TanNhatCMS](https://avatars.githubusercontent.com/u/113796420?v=4)](https://github.com/TanNhatCMS "TanNhatCMS (6 commits)")

### Embed Badge

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

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

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3416.9k](/packages/duncanmcclean-statamic-cargo)

PHPackages © 2026

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