PHPackages                             hmones/laravel-cacheable - 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. hmones/laravel-cacheable

ActiveLibrary[Caching](/categories/caching)

hmones/laravel-cacheable
========================

A simple package to automatically cache the returns of certain methods in a given class and forgets them as well on request.The package is highly configurable and let you manage naming of the cache keys with ease.

v1.0.0(3y ago)061MITPHPPHP ^7.4|^8.0

Since Jul 14Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel Cacheable
=================

[](#laravel-cacheable)

[![Build Status](https://github.com/hmones/laravel-cacheable/actions/workflows/build.yml/badge.svg)](https://github.com/hmones/laravel-cacheable/actions)[![Style CI](https://camo.githubusercontent.com/afa54f83a41dc0e96e95e75d310fd78aeb8cca368bf7e4c648870d898bfcc87b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3531333536343432352f736869656c64)](https://github.styleci.io/repos/513564425)[![Total Downloads](https://camo.githubusercontent.com/eefc77cdf90fda277764f25ea093313b7aca08c1d8484a1f83037daf49978229/687474703a2f2f706f7365722e707567782e6f72672f686d6f6e65732f6c61726176656c2d636163686561626c652f646f776e6c6f616473)](https://packagist.org/packages/hmones/laravel-cacheable)[![Latest Stable Version](https://camo.githubusercontent.com/ba6c5d5fafc47691e0d5da68fa90e9b9a5e536f67b2fb43a2f585c372d6b7873/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f686d6f6e65732f6c61726176656c2d636163686561626c65)](https://packagist.org/packages/hmones/laravel-cacheable)[![License](https://camo.githubusercontent.com/66a7a25d7b0c93d9f29062f5a9262d0b3ec45747af0220f83475106124e77335/687474703a2f2f706f7365722e707567782e6f72672f686d6f6e65732f6c61726176656c2d636163686561626c652f6c6963656e7365)](https://packagist.org/packages/hmones/laravel-cacheable)

A simple package to automatically cache the returns of certain methods in a given class and forgets them as well on request. The package is highly configurable and let you manage naming of the cache keys with ease.

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

[](#installation)

Via Composer

```
composer require hmones/laravel-cacheable
```

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

[](#configuration)

To publish the package configuration

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

The configuration file contains the following parameters:

- `ttl`: the default time to live for caching functions
    - Env variable: `CACHEABLE_TTL`
    - Default value: `3600`
- `param-keys-enabled` whether you would like to add function parameters to keys of the stored cache items. *Note:* Make sure that the parameters are strings or integers, otherwise adding the parameters wouldn't work.
    - Env variable: `CACHEABLE_PARAM_KEYS_ENABLED`
    - Default value: `false`
- `cache-tags-enabled` whether you would like to add tags as the method name to the cached keys, this will allow you to store multiple instances of the calls if you choose to add parameters to it, and then when you want to delete them all you can simply delete everything with this tag. The application takes care of that on it's own if you call `forgetCall` based on the settings you choose here.
    - Env variable: `CACHEABLE_TAGS`
    - Default value: `false`
- `prefix` if you would like to set a default prefix to all cacheable items
    - Env variable: `CACHEABLE_PREFIX`
    - Default value: ``
- `suffix` if you would like to set a default suffix to all cacheable items
    - Env variable: `CACHEABLE_SUFFFIX`
    - Default value: ``

Usage
-----

[](#usage)

- Make sure your class extend `\Hmones\LaravelCacheable\Cacheable`
- Instead of calling the method in the class directly, call `CLASS::cacheCall('methodName', ['argument1' => 'value', 'argument2' => 'value'])`
- You can remove the cached method call as follows:
    - If you have redis and/or any cache driver that supports tagging, even if you have enabled the parameters' addition to cache keys, you can simply call `CLASS::forgetCall('methodName)`
    - If you don't have a cache driver that supports tags, and you have enabled adding functions parameters to the cache, you must include the arguments in the forget call as follows: `CLASS::forgetCall('methodName', ['argument1' => 'value', 'argument2' => 'value'])`

Example: Sending a digest email every time 10 new users register on the website with a summary of their names.

Change log
----------

[](#change-log)

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

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [contributing.md](CONTRIBUTING.md) for details and a todolist.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Haytham Mones](https://github.com/hmones)

License
-------

[](#license)

Please see the [license file](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

1396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7da4fc759399b2b0a29e8a7266234caeb6d764fc9b34869ff0d2bb7c812464d1?d=identicon)[haythammones](/maintainers/haythammones)

---

Top Contributors

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

---

Tags

laravelLaravelCacheable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hmones-laravel-cacheable/health.svg)

```
[![Health](https://phpackages.com/badges/hmones-laravel-cacheable/health.svg)](https://phpackages.com/packages/hmones-laravel-cacheable)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

975163.6k2](/packages/awssat-laravel-visits)[namoshek/laravel-redis-sentinel

An extension of Laravels Redis driver which supports connecting to a Redis master through Redis Sentinel.

38679.0k](/packages/namoshek-laravel-redis-sentinel)[encore/redis-manager

Redis manager for laravel

25243.1k](/packages/encore-redis-manager)[dragon-code/laravel-cache

An improved interface for working with cache

6844.8k9](/packages/dragon-code-laravel-cache)[nexxai/laravel-cfcache

A handful of Cloudflare cache helpers for Laravel

1317.7k](/packages/nexxai-laravel-cfcache)

PHPackages © 2026

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