PHPackages                             caiquemcz/query-from-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. [Caching](/categories/caching)
4. /
5. caiquemcz/query-from-cache

ActiveLibrary[Caching](/categories/caching)

caiquemcz/query-from-cache
==========================

Query From Cache is a Laravel package that provides a simple way to cache query results directly from your Eloquent models. It automatically caches the output of model methods and offers actions to refresh or clear the cache with minimal code changes.

50PHPCI passing

Since Mar 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/CaiqueMcz/query-from-cache)[ Packagist](https://packagist.org/packages/caiquemcz/query-from-cache)[ RSS](/packages/caiquemcz-query-from-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Query From Cache
================

[](#query-from-cache)

Query From Cache is a Laravel package that provides a simple way to cache query results directly from your Eloquent models. It automatically caches the output of model methods and offers actions to refresh or clear the cache with minimal code changes.

Features
--------

[](#features)

- **Automatic Caching**: Call a method with the suffix `FromCache` and have its result cached.
- **Custom Cache Actions**: Use actions like **CREATE**, **REFRESH**, and **FORGET** to control cache behavior.
- **Configurable**: Easily adjust cache prefix, expiration time, and cache store via configuration.
- **Easy Integration**: Use a trait on your models to enable caching without modifying your existing methods.

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

[](#installation)

You can install the package via Composer:

```
composer require caiquemcz/query-from-cache
```

Then, register the service provider in your `config/app.php` if you are not using package auto-discovery:

```
'providers' => [
    // ...
    CaiqueMcz\QueryFromCache\QueryFromCacheServiceProvider::class,
],
```

Publish the configuration file to customize cache settings:

```
php artisan vendor:publish --tag=config
```

This will create a file named `query-from-cache.php` in your `config` folder.

Configuration
-------------

[](#configuration)

The published config file (`config/query-from-cache.php`) looks like this:

```
