PHPackages                             tequilarapido/result-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. tequilarapido/result-cache

ActiveLibrary[Caching](/categories/caching)

tequilarapido/result-cache
==========================

A simple and decoupled way to store resource consuming operations results in cache.

1.0.0(7y ago)129MITPHP

Since Oct 12Pushed 7y ago3 watchersCompare

[ Source](https://github.com/tequilarapido/result-cache)[ Packagist](https://packagist.org/packages/tequilarapido/result-cache)[ Docs](https://github.com/tequilarapido/result-cache)[ RSS](/packages/tequilarapido-result-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

A simple and decoupled way to store resource consuming operations results in cache.

[![Latest Version on Packagist](https://camo.githubusercontent.com/2ffaa7ba9c85ffe725c2c93690c75035d0a23e5140246f445de62163af66fb81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74657175696c6172617069646f2f726573756c742d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tequilarapido/result-cache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/62bdda321651b6636a8839b25b18f6c68b1726342fa4dae42a1aab95962c044e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f74657175696c6172617069646f2f726573756c742d63616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tequilarapido/result-cache)[![StyleCI](https://camo.githubusercontent.com/fec0b8ecf85e2c11d637bdec68cf1c7485ba623101227f09ba0c85eb631c7dc6/68747470733a2f2f7374796c6563692e696f2f7265706f732f37303236313539322f736869656c64)](https://styleci.io/repos/70685298)[![SensioLabsInsight](https://camo.githubusercontent.com/843ab887baf86fdbdfce45975d9585c76f6e0356f121cdcb26963be5825e3469/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f38396665663933372d303938332d346365612d383835382d3061336437343837356439632e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/89fef937-0983-4cea-8858-0a3d74875d9c)[![Quality Score](https://camo.githubusercontent.com/f2d5712c51c796e6e07563fd39a7bc0a0f247055c6952d47cac7433ae4b5b683/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74657175696c6172617069646f2f726573756c742d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tequilarapido/result-cache)[![Code Coverage](https://camo.githubusercontent.com/8e0cf36e796f31d458e0135ad4f41f469644b23742ed7eed7a447bc19371fdd8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74657175696c6172617069646f2f726573756c742d63616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tequilarapido/result-cache/?branch=master)

 [![Laravel Translation Sheet](https://camo.githubusercontent.com/c2290b3345f96ea7faea1666564e0206e6017dd4305c45e4dacb9a4064a87cad/68747470733a2f2f7331382e706f7374696d672e6f72672f6f6c776863383561312f696c6c757374726174696f6e2e6a7067)](https://camo.githubusercontent.com/c2290b3345f96ea7faea1666564e0206e6017dd4305c45e4dacb9a4064a87cad/68747470733a2f2f7331382e706f7374696d672e6f72672f6f6c776863383561312f696c6c757374726174696f6e2e6a7067)

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package using composer

```
$ composer require tequilarapido/result-cache
```

Usage
-----

[](#usage)

### Cache

[](#cache)

- Create a class that extends ResultCache

```
use Tequilarapido\ResultCache\ResultCache;

class BooksCache extends ResultCache {

    public function key() {
        return 'app.books.all';
    }

    public function data() {
        // Some heavy / resources consuming operations
        // ...
        return $books;
    }
}
```

- Now you can simply call the get method to fetch cache. If the cache is invalid or not yet created, the operations will be executed.

```
class SomeController {
    public function books() {
          return (new BooksCache)->get();
    }
}
```

- Clean the cache

The package uses the default cache driver defined in your laravel application.

You can clean the cache using the `artisan cache:clear`

You can also clean the cache programmatically using :

```
  (new BooksCache)->forget()
```

### Application locale aware cache

[](#application-locale-aware-cache)

Sometimes we need to cache something, but we need multiple versions depending on the application locale. For this kind of use case we need to extend the `LocaleAwareResultCache`, and define the locales that are available in our application.

- Create a class that extends LocaleAwareResultCache

```
use Tequilarapido\ResultCache\LocaleAwareResultCache;

class BooksCache extends LocaleAwareResultCache {

    public function key() {
        return 'app.books.all';
    }

    public function data() {
        // Some heavy / resources consuming operations
        // We have access to $this->locale here to customize results according to locale
        // ...
        return $books;
    }

    public function  supportedLocales() {
        return ['en', 'fr', 'ar']
    }
}
```

- Now you can simply call the get method to fetch cache. If the cache is invalid or not yet created, the operations will be executed.

```
class SomeController {
    public function books() {
         return (new BooksCache)->setLocale($locale)->get();
    }
}
```

- Clean the cache

The package uses the default cache driver defined in your laravel application.

You can clean the cache using the `artisan cache:clear`

You can also clean the cache programmatically using :

```
  (new BooksCache)->forget()
```

this will clean cache for all locales.

### Cache expiration

[](#cache-expiration)

By default, cache is created for one day. You can override the protected `$minutes` property on your cache class to specify how much minutes you want your cache before it gets invalidated.

```
use Tequilarapido\ResultCache\ResultCache;

class BooksCache extends ResultCache {

    protected $minutes = 60; // One hour

    // ...
}
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email :author\_email instead of using the issue tracker.

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

[](#contributing)

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

Credits
-------

[](#credits)

- [Nassif Bourguig](https://github.com/nbourguig)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

3

Last Release

2791d ago

Major Versions

0.0.2 → 1.0.02018-09-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/2357415d73716a023601d0bc95812c5160ff977f17da9d43fbdc40b047a05c50?d=identicon)[nbourguig](/maintainers/nbourguig)

---

Top Contributors

[![nbourguig](https://avatars.githubusercontent.com/u/276832?v=4)](https://github.com/nbourguig "nbourguig (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tequilarapido-result-cache/health.svg)

```
[![Health](https://phpackages.com/badges/tequilarapido-result-cache/health.svg)](https://phpackages.com/packages/tequilarapido-result-cache)
```

###  Alternatives

[imanghafoori/laravel-widgetize

A minimal yet powerful package to give a better structure and caching opportunity for your Laravel apps.

909137.9k11](/packages/imanghafoori-laravel-widgetize)[swayok/alternative-laravel-cache

Replacements for Laravel's redis and file cache stores that properly implement tagging idea. Powered by cache pool implementations provided by http://www.php-cache.com/

202541.1k6](/packages/swayok-alternative-laravel-cache)[alexmg86/laravel-sub-query

Laravel subquery

7538.4k](/packages/alexmg86-laravel-sub-query)[laravel-enso/rememberable

Model caching dependency for Laravel Enso

2863.2k23](/packages/laravel-enso-rememberable)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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