Download the PHP package temperworks/laravel-russian-doll-cache without Composer
On this page you can find all versions of the php package temperworks/laravel-russian-doll-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download temperworks/laravel-russian-doll-cache
More information about temperworks/laravel-russian-doll-cache
Files in temperworks/laravel-russian-doll-cache
Package laravel-russian-doll-cache
Short Description Laravel Russian Doll Cache Blade Directive
License MIT
Homepage https://github.com/temperworks/laravel-russian-doll-cache
Informations about the package laravel-russian-doll-cache
Laravel Russian Doll Cache Blade Directive
Intro
This package provides a Blade directive to cache rendered partials in Laravel, based on the LRU auto evict policy of memcached (by default) or redis (optional)
In this implementation you don't need to explicitly set cache keys. The cache key will be automatically generated based on the data you pass to the partial.
If the data implements (by including the Cacheable trait) the key is based on the class, id and updated_at timestamp of the object. When the object changes, the key updates and the view will be regenerated on the next visit.
If the data does not implement , an md5 hash is used as cache key.
The cache store will be responsible for auto evicting the less recently used keys when the store is full.
Install
Make sure your cache store has configured and a proper eviction policy is set.
You can install the package via Composer:
Start by registering the package's service provider and facade:
Usage
The package registers a blade directive, @cache
. The cache directive accepts the same arguments as @include
, plus optional parameters for the amount of minutes a view should be cached for. If no minutes are provided, the view will be remembered untill it gets deleted by the cache store.
Only the data you pass explicitly to the partial will be available within. Unlike the behavior of @include
, global variables will be ignored to make sure all the variables will be represented in the cache key.
Clearing The PartialCache
Since we rely on the cache store to automatically flush old data, it's not needed to manually remove keys.
If you want to flush all entries, you'll need to either call PartialCache::flush()
(note: this is only supported by drivers that support tags), or clear your entire cache.
Configuration
Configuration isn't necessary, but there are some options specified in the config file:
russian-doll-cache.enabled
: Fully enable or disable the cache. Defaults totrue
.russian-doll-cache.directive
: The name of the blade directive to register. Defaults tocache
.russian-doll-cache.key
: The base key that used for cache entries. Defaults topartialcache
.
Credits
This package is forked from on spatie-partialcache by the awesome webdesign agency Spatie.
- Jeroen Jochems
- Sebastian De Deyne
- All Contributors
License
The MIT License (MIT). Please see License File for more information.