Download the PHP package berthott/laravel-api-cache without Composer
On this page you can find all versions of the php package berthott/laravel-api-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download berthott/laravel-api-cache
More information about berthott/laravel-api-cache
Files in berthott/laravel-api-cache
Download berthott/laravel-api-cache
More information about berthott/laravel-api-cache
Files in berthott/laravel-api-cache
Vendor berthott
Package laravel-api-cache
Short Description Laravel Helper for Caching API Responses
License MIT
Package laravel-api-cache
Short Description Laravel Helper for Caching API Responses
License MIT
Please rate this library. Is it a good library?
Informations about the package laravel-api-cache
Laravel-API-Cache
A helper for caching complete API Responses. Easily cache the complete response of you Laravel API.
Installation
Usage
- The package automatically caches all responses to GET requests when installed and enabled.
- The package assumes, that your routes are named according to Laravels Route::apiResource helper (
tablename.method
). - Responses are grouped via the table name (more specifically the first part of the route name, so custom route names are supported too).
- The package assumes, that your routes are named according to Laravels Route::apiResource helper (
- To automatically flush the cache corresponding to your model add the
FlushesApiCache
Trait to your model.- This will flush the cache for any model creation, update or deletion.
- To also flush dependent models override the Traits
cacheDependencies
method and return a list of related route names.
- A
FlushApiCache
event listener is available to be connected with custom model events.
Options
To change the default options use
enabled
: Enable the API caching. Default toenv('CACHE_API', false)
.ignoreRoutes
: An array of route names to be ignored from the cache. Defaults to[]
.lifetime
: The lifetime of the cache in days. Defaults to14
.key
: A key to add to each redis cache to be able to use a single redis server and avoid name clashes. Defaults toenv('CACHE_API_KEY', env('APP_NAME', 'laravel'))
.
Architecture
- The actual caching is done in
ApiCacheService
- A store-key is used to connect requests / cached responses to a specific model / entity
- An
ApiCacheMiddleware
intercepts all http requests and callsApiCacheService
- The
FlushesApiCache
trait observes creating / updating / deleting models and will clear the cache for the corresponding store
Compatibility
Tested with Laravel 10.x.
License
See License File. Copyright © 2023 Jan Bladt.
All versions of laravel-api-cache with dependencies
PHP Build Version
Package Version
No informations.
The package berthott/laravel-api-cache contains the following files
Loading the files please wait ....