PHPackages                             mconsult/rememberable - 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. mconsult/rememberable

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

mconsult/rememberable
=====================

Query caching for Laravel. This package is forked from dwightwatson/rememberable. All credit to him

6.2.5(1y ago)0679MITPHPPHP ^8.0

Since Aug 12Pushed 1y agoCompare

[ Source](https://github.com/MillerlandyConsult/rememberable)[ Packagist](https://packagist.org/packages/mconsult/rememberable)[ RSS](/packages/mconsult-rememberable/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Rememberable, Laravel query cache
=================================

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

[![Total Downloads](https://camo.githubusercontent.com/13df282d1d9e83734891623664d7013222fa06f38b335d24e3db5411bd7b33a6/68747470733a2f2f706f7365722e707567782e6f72672f776174736f6e2f72656d656d62657261626c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/watson/rememberable)[![Latest Stable Version](https://camo.githubusercontent.com/e0a19c2b3eab5fb2a3dfd4fb8442ff71b8e29b0a8cb7ae1ef6b6860a9f6891b9/68747470733a2f2f706f7365722e707567782e6f72672f776174736f6e2f72656d656d62657261626c652f762f737461626c652e737667)](https://packagist.org/packages/watson/rememberable)[![Latest Unstable Version](https://camo.githubusercontent.com/91a47e73278c2509bb5a43664afe5c0747da50ddd7db65a49ca0472420642a02/68747470733a2f2f706f7365722e707567782e6f72672f776174736f6e2f72656d656d62657261626c652f762f756e737461626c652e737667)](https://packagist.org/packages/watson/rememberable)[![License](https://camo.githubusercontent.com/6f50ddfdb48905c43d0e02dae8dc86b52806a92fcbc71f777df889c54030237d/68747470733a2f2f706f7365722e707567782e6f72672f776174736f6e2f72656d656d62657261626c652f6c6963656e73652e737667)](https://packagist.org/packages/watson/rememberable)

This package is forked from [dwightwatson/rememberable](https://github.com/dwightwatson/rememberable) for flexibility in our company projects. Whe change the namespaces due to security audit requirements. Thank you for your package [Dwight Watson](https://github.com/dwightwatson) ❤️

Rememberable is an Eloquent trait for Laravel that adds `remember()` query methods. This makes it super easy to cache your query results for an adjustable amount of time.

```
// Get a the first user's posts and remember them for a day.
User::first()->remember(now()->addDay())->posts()->get();

// You can also pass the number of seconds if you like (before Laravel 5.8 this will be interpreted as minutes).
User::first()->remember(60 * 60 * 24)->posts()->get();
```

It works by simply remembering the SQL query that was used and storing the result. If the same query is attempted while the cache is persisted it will be retrieved from the store instead of hitting your database again.

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

[](#installation)

Install using Composer, just as you would anything else.

```
composer require watson/rememberable
```

The easiest way to get started with Eloquent is to create an abstract `App\Model` which you can extend your application models from. In this base model you can import the rememberable trait which will extend the same caching functionality to any queries you build off your model.

```
