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

ActiveLibrary

khophim8k/laravel-caching-model
===============================

A simple cache library for laravel eloquent model

v1.1.0(1y ago)0821MITPHPPHP ^7.0|^8.0

Since Oct 15Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)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 Khophim8k\CachingModel\Contracts\Cacheable;
use Khophim8k\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

27

—

LowBetter than 49% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

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

Unknown

Total

1

Last Release

574d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51cecd6b4ad11aa07056f9e642afc41d59fac7db76bde6c577d09071ac4ea8d7?d=identicon)[hieudangdev](/maintainers/hieudangdev)

---

Top Contributors

[![hieudangdev](https://avatars.githubusercontent.com/u/93910239?v=4)](https://github.com/hieudangdev "hieudangdev (1 commits)")

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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