2017 © Pedro Peláez
 

library laravel-multi-cache

Combine multiple caches in Laravel 5.

image

tmd/laravel-multi-cache

Combine multiple caches in Laravel 5.

  • Saturday, February 25, 2017
  • by antriver
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 122 % Grown

The README.md

Laravel Multi Cache

Allows you to use multiple Laravel cache stores as one. Retrieves items from the first cache they are found in., (*1)

An example use is to have an array cache and Redis cache. Fetch items from the array cache first (faster), and from Redis if the key was not found. The value will be stored in the array cache if it was found in Redis., (*2)

Installation

composer require antriver/laravel-multi-cache

Add this to your config/app.php providers array:, (*3)

Antriver\LaravelMultiCache\MultiStoreServiceProvider::class

Add the multi store to your config/cache.php stores array:, (*4)

    'stores' => [
        'array' => [
            'driver' => 'array',
        ],
        'database' => [
            'driver' => 'database',
            'table'  => 'cache',
            'connection' => null,
        ],
        'redis' => [
            'driver' => 'redis',
            'connection' => 'redis-cache',
        ],
        'multi' => [
            'driver' => 'multi',
            'stores' => [
                'array',
                'redis',
                'database'
            ]
        ]
    ],

Set your CACHE_DRIVER in .env:, (*5)

CACHE_DRIVER=multi

Usage

The cache implements the standard cache interface, so you use all the normal get() and put() methods., (*6)

get($key)

Returns the value from the first store $key is found in (in the order defined in stores). The value will be saved in any higher 'stores'. e.g. If the value is not found it array, but is in redis, the value from redis will be returned and put in array, but it will not be put in database., (*7)

put($key, $value, $minutes)

Stores an item in all of the stores., (*8)

All of the other methods (increment(), forget(), flush(), etc.) perform the operation on all of the stores., (*9)

The Versions

25/02 2017

dev-master

9999999-dev

Combine multiple caches in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/02 2017

1.0.0

1.0.0.0

Combine multiple caches in Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires