2017 © Pedro Peláez
 

library russian-doll-caching

Laravel Russian Doll Caching

image

rodrigopedra/russian-doll-caching

Laravel Russian Doll Caching

  • Friday, February 16, 2018
  • by rodrigo.pedra
  • Repository
  • 1 Watchers
  • 7 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 10 % Grown

The README.md

Russian Doll Caching for Laravel 5.3, 5.4, 5.5 and 5.6

Efficient view caching., (*1)

Inspired by the excellent series at https://laracasts.com/series/russian-doll-caching-in-laravel ., (*2)

Watch that series to understand the concepts around it and to use it properly, for example: how to invalidate the cache upwards., (*3)

Installation

In your terminal/shell run:, (*4)

composer require rodrigopedra/russian-doll-caching

If you're using Laravel 5.3 or 5.4 you need to register the service provider in your config/app.php providers array:, (*5)

// ... 

'providers' => [
    // ... 

    RodrigoPedra\RussianDollCaching\RussianDollCachingServiceProvider::class,
],

// ... 

Configuration

In your terminal/shell run:, (*6)

php artisan vendor:publish --provider="RodrigoPedra\RussianDollCaching\RussianDollCachingServiceProvider"

You can configure a should_cache constraint, so you can skip caching, for example, while developing locally., (*7)

Usage

Use the @russian directive in your blade templates the same way you would use the @include directive., (*8)

You can optionally inform a custom prefix that will be prepended to the cache key., (*9)

    @russian('path.to.view', compact('user', 'articles'), 'version-prefix')

    @russian('path.to.other.view', compact('user', 'articles'))

    {{-- caution here, the cache key will only be the view name hash! --}}
    @russian('path.to.another.view')

You can also pass multiple prefixes as an array, that will be prepended to the cache item's key:, (*10)

    @russian('path.to.other.view', compact('user'), [ 'v1', 'home' ])

If your cache mechanism supports tagging, like memcached or redis, all cache items will be cached with a russian tag., (*11)

Key calculation

The caching mechanism will try to use the first element in the data array as part of the cache key., (*12)

You should use the RussianCacheableModel trait in your models or use the RussianCacheableCollection in your custom collections. This traits add a getCacheKey method to this objects so you can, (*13)

FAQ

  • Why are my views not updating?, (*14)

    Try running php artisan view:clear and php artisan cache:clear. Also, while developing, set the should_cache config key to false., (*15)

  • Can I flush just the items cached by this package?, (*16)

    If you use a caching mechanism that supports tagging (memcached or redis) all the cached items are created with a russian tag. So you can clear only these items running \Cache::tags('russian')->flush() in php artisan tinker, (*17)

License

This package is open-sourced software licensed under the MIT license., (*18)

The Versions

16/02 2018

dev-master

9999999-dev

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

16/02 2018

v2.0.0

2.0.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

12/02 2016

v1.3.3

1.3.3.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.3.2

1.3.2.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.3.1

1.3.1.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.3

1.3.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.2.1

1.2.1.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.2

1.2.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.1.0

1.1.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v1.0

1.0.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra

11/02 2016

v0.1

0.1.0.0

Laravel Russian Doll Caching

  Sources   Download

MIT

The Requires

 

by Rodrigo Pedra Brum

laravel russian doll caching rodrigopedra