New

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

valeryq/cacheable

Laravel Cacheable
101 5
Install
composer require valeryq/cacheable
Latest Version:v1.1.0
PHP:>=5.5.9
Laravel:5
License:MIT
Last Updated:May 10, 2016
Links: GitHub  ·  Packagist
Maintainer: valeryq

Laravel Cacheable

Build Status Scrutinizer Scrutinizer Code Quality Total Downloads Latest Stable Version License

Requirements

  • PHP >= 5.5.9
  • Laravel >= 5.1

Installation

Require this package with composer:

composer require valeryq/cacheable

Usage

You must implements the Cacheable contract into your class and you can use the CacheableTrait instead realized methods from contract.

For example (for repositories):

<?php namespace App\Repositories\Cacheable;

use App\Models\Product;
use Valeryq\Cacheable\Contracts\Cacheable;
use Valeryq\Cacheable\Traits\CacheableTrait;

class CacheableProductRepository implements Cacheable
{
    use CacheableTrait;

    /**
     * Find product by id
     *
     * @param $id
     *
     * @return Product
     * @throws ModelNotFoundException
     */
    public function find($id)
    {
        return $this->cache()->remember('your_key', 60, function() {
            return Product::findOrFail($id);
        });
    }

    ....
}

License

The Laravel Cacheable is open-sourced software licensed under the MIT license

Related Packages

bunkuris/has-cache

HasCache trait for Laravel models with cache key managers

3,573 0
silber/page-cache

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

519,531 1,258
laracasts/matryoshka

Russian Doll Caching for Laravel.

60,984 237
geekcache/geekcache

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

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

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

32,094 3

Version History

Version Released PHP Laravel License
v1.1.0 >=5.5.9 ^5.1 MIT
v1.0.0 >=5.5.9 ^5.1 MIT