Download the PHP package ulex/cached-repositories without Composer
On this page you can find all versions of the php package ulex/cached-repositories. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ulex/cached-repositories
More information about ulex/cached-repositories
Files in ulex/cached-repositories
Package cached-repositories
Short Description Cached Repositories - A simple Laravel package
License MIT
Informations about the package cached-repositories
Centralize and cache you application's queries
Documentation, Installation, and Usage Instructions
First, install the package via Composer:
Service Provider
For Laravel
You should publish the RepositoriesServiceProvider:
Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file: Laravel
For Lumen
In your bootstrap/app.php
:
-
Register the provider
- Register config
Config
If config file cached-repositories.php
was not published copy it to config folder with:
Create Repository, Interface, Decorator for a Model
Run the following php artisan command where the argument is your Model name (example Post):
Expected Result:
The following folders will be created in your app/Repositories
folder (if they don't exist):
As seen in the result remember to add the Model in config/cached-repositories.php
:
How to use
This package provides an abstract structure that uses the Repository design pattern with caching decorators for you application.
Once installed you can create Repositories for your models that cache the data from your queries. EloquentRepository is provided and ready to use. Follow the same principle for any data resource you have on your application.
Extending a model's CachingDecorator
For GET functions use remember
function the same way as in the abstract CachingDecorator. This will ensure that this function is cached properly.
UserCachingDecorator.php
Note: Remember to add the cache invalidation of the new function by extending flushGetKeys in the model's CachingDecorator.
UserRepository.php
Add the query in the model's repository
Contributing
This package is mostly based on Jeffrey Way's awesome Laracasts lessons when using the repository design pattern on Laravel From Scratch series.
License
The MIT License (MIT). Please see License File for more information.