PHPackages                             atldays/laravel-eloquent-query-cache - 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. [Database &amp; ORM](/categories/database)
4. /
5. atldays/laravel-eloquent-query-cache

ActiveLibrary[Database &amp; ORM](/categories/database)

atldays/laravel-eloquent-query-cache
====================================

Adding cache on your Laravel Eloquent queries' results is now a breeze.

v1.1.0(1mo ago)0511Apache-2.0PHPCI passing

Since Apr 11Pushed 1mo agoCompare

[ Source](https://github.com/atldays/laravel-eloquent-query-cache)[ Packagist](https://packagist.org/packages/atldays/laravel-eloquent-query-cache)[ Docs](https://github.com/atldays/laravel-eloquent-query-cache)[ RSS](/packages/atldays-laravel-eloquent-query-cache/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (9)Versions (4)Used By (1)

Laravel Eloquent Query Cache
============================

[](#laravel-eloquent-query-cache)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9ae29cb4fbe9d94ecef7d25374cb77f45e1332d646700b34254c4b4980066ece/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61746c646179732f6c61726176656c2d656c6f7175656e742d71756572792d63616368652e7376673f6c6f676f3d7061636b6167697374267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/atldays/laravel-eloquent-query-cache)[![Total Downloads](https://camo.githubusercontent.com/49b3f7f01589cd4ee8dfa51110577add8ad6372402a824172f8f9bdf32de447c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61746c646179732f6c61726176656c2d656c6f7175656e742d71756572792d63616368652e7376673f7374796c653d666f722d7468652d626164676526636f6c6f723d626c7565)](https://packagist.org/packages/atldays/laravel-eloquent-query-cache)[![CI](https://camo.githubusercontent.com/5191dfc073604647e970cdea4dbcfe3dbc90e592611f8e0a5a67eb72402815eb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61746c646179732f6c61726176656c2d656c6f7175656e742d71756572792d63616368652f63692e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d4349)](https://github.com/atldays/laravel-eloquent-query-cache/actions/workflows/ci.yml)[![License: Apache-2.0](https://camo.githubusercontent.com/bde453f7b5dcc28d625f5e75cb9da9645b204dd3662d2ff4b6b2ceaafafc99ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d79656c6c6f772e7376673f7374796c653d666f722d7468652d6261646765)](LICENSE.md)

`atldays/laravel-eloquent-query-cache` is a maintained fork of the original `rennokki/laravel-eloquent-query-cache` package.

- Original repository: [rennokki/laravel-eloquent-query-cache](https://github.com/renoki-co/laravel-eloquent-query-cache)
- Original documentation: [rennokki.gitbook.io/laravel-eloquent-query-cache](https://rennokki.gitbook.io/laravel-eloquent-query-cache/)

If you only need the core package behavior, use the original documentation above. This fork keeps the original package experience and adds a few improvements for modern Laravel applications and additional relationship caching scenarios.

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

[](#installation)

```
composer require atldays/laravel-eloquent-query-cache
```

Use the trait on models where query caching should be available:

```
use Atldays\QueryCache\Traits\QueryCacheable;

class Post extends Model
{
    use QueryCacheable;
}
```

What This Fork Adds
-------------------

[](#what-this-fork-adds)

### `MorphTo` caching support

[](#morphto-caching-support)

The original package documentation covers the general caching API. This fork additionally supports cached `morphTo` relations with inherited cache configuration.

```
$commentable = $comment->commentable()
    ->cacheFor(now()->addHour())
    ->cacheTags(['commentable'])
    ->cachePrefix('comments')
    ->withPlainKey()
    ->first();
```

This is useful when you want polymorphic relations to behave the same way as the rest of your cached query chains.

### Cache configuration inheritance for relationships

[](#cache-configuration-inheritance-for-relationships)

Custom cache options can now flow more consistently into supported relationship queries.

Typical examples:

- `cacheFor(...)`
- `cacheTags([...])`
- `cachePrefix(...)`
- `withPlainKey()`
- `cacheDriver(...)`

### Custom cache repository support

[](#custom-cache-repository-support)

In addition to passing a driver name, you can pass a cache repository instance to `cacheDriver()`:

```
use Illuminate\Support\Facades\Cache;

$posts = Post::query()
    ->cacheFor(300)
    ->cacheDriver(Cache::store('array'))
    ->get();
```

This is helpful when integrating the package into more customized application setups or when testing specific cache stores.

Using The Core API
------------------

[](#using-the-core-api)

The core query cache API remains aligned with the original package documentation. For the full feature set and the original behavior reference, see:

- [Original package repository](https://github.com/renoki-co/laravel-eloquent-query-cache)
- [Original documentation](https://rennokki.gitbook.io/laravel-eloquent-query-cache/)

Common examples:

```
$posts = Post::cacheFor(3600)->get();

$post = Post::cacheFor(now()->addHour())->first();

$uncached = Post::dontCache()->get();

$tagged = Post::cacheFor(600)->cacheTags(['posts'])->get();
```

Testing
-------

[](#testing)

```
vendor/bin/pint --test
vendor/bin/phpunit
```

If you run the project through Docker, the commands used in this repository are:

```
docker run --rm -u $(id -u):$(id -g) -v "$PWD:/app" -w /app composer:2 sh -lc 'vendor/bin/pint --test'
docker run --rm -u $(id -u):$(id -g) -v "$PWD:/app" -w /app composer:2 sh -lc 'composer test'
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover a security issue, please open a private report with the repository maintainers instead of posting sensitive details publicly.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance89

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75.9% 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

2

Last Release

57d ago

### Community

Maintainers

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

---

Top Contributors

[![rennokki](https://avatars.githubusercontent.com/u/21983456?v=4)](https://github.com/rennokki "rennokki (202 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (26 commits)")[![atldays](https://avatars.githubusercontent.com/u/130153594?v=4)](https://github.com/atldays "atldays (20 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![giannicic](https://avatars.githubusercontent.com/u/10560238?v=4)](https://github.com/giannicic "giannicic (3 commits)")[![advil0](https://avatars.githubusercontent.com/u/313308?v=4)](https://github.com/advil0 "advil0 (3 commits)")[![squatto](https://avatars.githubusercontent.com/u/748444?v=4)](https://github.com/squatto "squatto (1 commits)")[![s-shiryaev](https://avatars.githubusercontent.com/u/33102548?v=4)](https://github.com/s-shiryaev "s-shiryaev (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![DeepDiver1975](https://avatars.githubusercontent.com/u/1005065?v=4)](https://github.com/DeepDiver1975 "DeepDiver1975 (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")[![devajmeireles](https://avatars.githubusercontent.com/u/60591772?v=4)](https://github.com/devajmeireles "devajmeireles (1 commits)")[![Jampire](https://avatars.githubusercontent.com/u/686954?v=4)](https://github.com/Jampire "Jampire (1 commits)")[![shinsenter](https://avatars.githubusercontent.com/u/2082119?v=4)](https://github.com/shinsenter "shinsenter (1 commits)")

---

Tags

cacheeloquentlaravelphpquery-builderlaravelsqleloquentcachingqueryrememberatldays

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/atldays-laravel-eloquent-query-cache/health.svg)

```
[![Health](https://phpackages.com/badges/atldays-laravel-eloquent-query-cache/health.svg)](https://phpackages.com/packages/atldays-laravel-eloquent-query-cache)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M84](/packages/mongodb-laravel-mongodb)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.2M14](/packages/rennokki-laravel-eloquent-query-cache)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M16](/packages/reedware-laravel-relation-joins)[ntanduy/cloudflare-d1-database

Cloudflare D1 database driver for Laravel — full Eloquent &amp; Query Builder support.

246.8k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

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