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

ActiveLibrary[Caching](/categories/caching)

mahmoud217tr/cacheable
======================

Laravel package for easing and enhance caching for models and cacheable classes

1.0.0(2y ago)112[5 PRs](https://github.com/Mahmoud217TR/cacheable/pulls)MITPHPPHP ^8.0CI passing

Since Jun 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Mahmoud217TR/cacheable)[ Packagist](https://packagist.org/packages/mahmoud217tr/cacheable)[ Docs](https://github.com/mahmoud217tr/cacheable)[ GitHub Sponsors](https://github.com/Mahmoud217TR)[ RSS](/packages/mahmoud217tr-cacheable/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (14)Versions (7)Used By (0)

Cacheable for Laravel
=====================

[](#cacheable-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/68e6aeb1a21325549742d78667df72a5bd3fc043983a32bfb1ce4fe378d674e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61686d6f756432313774722f636163686561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mahmoud217tr/cacheable)[![GitHub Tests Action Status](https://camo.githubusercontent.com/53973e514e45c3d99d52e6de79e151204342b2621ff2546856e4d573ba071a5d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61686d6f756432313774722f636163686561626c652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mahmoud217tr/cacheable/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a28eeb648eecab3fd2f18e13c4826185c99fcfcff8dd78cc6dbd8b5dbff68b8c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61686d6f756432313774722f636163686561626c652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/mahmoud217tr/cacheable/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/f0ce609ad5225f25e270a83fbad1378847ff4fb7ef743d7fb44581e1a79d2ac6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61686d6f756432313774722f636163686561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mahmoud217tr/cacheable)

**Effortless and Enhanced Caching for Models and Classes**

Laravel package that provides a streamlined and powerful solution for implementing caching within your application. This package simplifies the process of caching Eloquent models and other classes, ensuring improved performance and scalability for your Laravel application.

[![logo](/assets/cacheable.svg)](/assets/cacheable.svg)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    1. [Cacheable Models](#1-cacheable-models)
        1. [Easy Caching for Model Records and Collections](#1-easy-caching-for-model-records-and-collections)
        2. [Auto-Caching Model Records](#2-auto-caching-model-records)
        3. [Cached Route Model Binding](#3-cached-route-model-binding)
    2. [Cacheable Interface &amp; Trait](#2-cacheable-interface--trait)
    3. [Cacheable Facade](#3-cacheable-facade)
    4. [Helper Functions](#4-helper-functions)
- [Publishing](#publishing)
- [Testing](#testing)
- [Changelog](#changelog)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

To install the package to your Laravel project via Composer:

```
composer require mahmoud217tr/cacheable
```

And once the installation is complete, the package will be ready up and ready for usage.

Usage
-----

[](#usage)

There is a lot of features and usecases we will summerize them with the following:

### 1. Cacheable Models

[](#1-cacheable-models)

You can make the model cacheable by making it implement `CacheableModel` interface and use the `CacheableModelTrait` trait as the following example:

```
