Download the PHP package suitmedia/laravel-cacheable without Composer
On this page you can find all versions of the php package suitmedia/laravel-cacheable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download suitmedia/laravel-cacheable
More information about suitmedia/laravel-cacheable
Files in suitmedia/laravel-cacheable
Package laravel-cacheable
Short Description Decorate your repositories and make them cacheable
License MIT
Homepage https://github.com/suitmedia/laravel-cacheable
Informations about the package laravel-cacheable
Laravel Cacheable
Decorate your repositories and make them cacheable
Synopsis
This package will help you to make your repositories cacheable without worrying about how to manage the cache, and provide an easy way to invalidate the cache. Laravel Cacheable package uses a dynamic decorator class to wrap your existing repository and add the auto-caching feature into it.
Table of contents
- Compatibility
- Requirements
- Setup
- Configuration
- Usage
- License
Compatibility
Laravel version | Cacheable version |
---|---|
5.1.x - 5.4.x | 1.0.x - 1.3.x |
5.5.x - 5.8.x | 1.4.x |
6.x | 1.5.x |
7.x | 1.6.x |
8.x | 1.7.x |
9.x | 1.9.x - 1.10.x |
10.x | 1.11.x |
11.x | 1.12.x |
Requirements
This package require you to use cache storage which supports tags like memcached or redis. You will get errors if you use this package while using any cache storage which does not support tags.
Setup
Install the package via Composer :
If you are using Laravel version 5.5+ then you can skip registering the service provider and package alias in your application.
Register The Service Provider
Add the package service provider in your config/app.php
Register The Package Alias
Add the package alias in your config/app.php
Configuration
Publish configuration file using php artisan
command
The command above would copy a new configuration file to /config/cacheable.php
Usage
Prepare Your Model
Every Model that you wish to be cached should implement the CacheableModel
contract and use the CacheableTrait
. The trait will add extra features to your model and observe your model for any future changes. This way, the package will notice whenever the observed model get updated and then it will flush the cache related to the affected model immediately.
Prepare Your Repository
Every Repository that you need to be cached also have to implements the CacheableRepository
contract. You can implements the contract simply by using the CacheableTrait
like this :
Retrieve Data From Repository And Cache The Result
With this package, you won't need to create new classes to decorate each of your repositories. You can just decorate them using the Cacheable
facade, and all results of the repository's methods will be cached automatically.
Cache Invalidation
This package will help you to invalidate the cache automatically whenever the CacheableModel
is updated. It will invalidate the cache based on the cache tags which have been defined in your model.
But, you can also invalidate the cache manually using the Cacheable
facade.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-cacheable with dependencies
illuminate/cache Version ^8.0|^9.0|^10.0|^11.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0