New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

masnun/cache

A package that allows you to use two caching engines, one as a fallback for the other
8 1
Install
composer require masnun/cache:dev-master
PHP:>=5.4.0
Last Updated:Oct 12, 2014
Links: GitHub  ·  Packagist
Maintainer: masnun

Cache

A laravel package that allows using two caching engines, one as a fallback for the other

Installation

Add the following to your composer.json file's require section:

	"masnun/cache": "dev-master"

Run composer update. Composer should install the latest version of the package.

Now, register the Service Provider in app/config/app.php file. Add the following line to the providers array:

'Masnun\Cache\CacheServiceProvider'

You should next register an alias for the API. We recommend MCache. Add the following line to the aliases array in the same file:

'MCache'  => 'Masnun\Cache\CacheFacade',

Let's publish the configuration values for the package. Execute from the command line:

php artisan config:publish masnun/cache

The configuration file will be published to app/config/packages/masnun/cache/cache.php. Please feel free to tweak the values. Here's a short description:

  • primary - the name of the primary cache driver (eg. 'memcached' for memcached )
  • secondary - the name of the fallback cache driver
  • default_expiration - the default value for cache expiration
  • async - should the data be offloaded using background async queues?
  • async_driver - if yes, then using which queue driver?

(PS: The async data offloading still not implemented, it's work in progress).

Code Sample

Route::get('/', function ()
{
    MCache::put('name', 'masnun', 60);
    return MCache::get('name');
});

Please feel free to be creative and try the usual Cache APIs. Here's a list of currently implemented methods:

  • put()
  • add()
  • has()
  • get()
  • forever()
  • remember()
  • rememberForever()
  • pull()
  • forget()

Related Packages

bunkuris/has-cache

HasCache trait for Laravel models with cache key managers

3,639 0
silber/page-cache

Caches responses as static files on disk for lightning fast page loads.

530,502 1,262
laracasts/matryoshka

Russian Doll Caching for Laravel.

61,004 237
geekcache/geekcache

A wrapper for Memcached with tags, soft invalidation, memoization, and regenerat...

38,912 6
mitydigital/statamic-scheduled-cache-invalidator

A command to help invalidate the cache when scheduled Statamic entries are due t...

34,254 3