tarkhov/eloquent-cache

Laravel Eloquent model cache.

v0.1.0 2018-03-12 03:05 UTC

This package is auto-updated.

Last update: 2024-04-13 05:16:31 UTC


README

Laravel Eloqeunt model auto caching.

Contents

  1. Compatibility
  2. Installation
    1. Composer
  3. Usage
    1. Inherit model
  4. Author
  5. License

Compatibility

Library Version
Laravel 5.5

Installation

Composer

composer require tarkhov/eloquent-cache

Usage

Inherit model

Start using caching features by inheriting CacheModel class.

<?php
namespace App;

use EloquentCache\Database\Eloquent\CacheModel;

class Post extends CacheModel
{
    protected $fillable = [
        'category_id',
        'title',
        'description',
    ];

    public function category()
    {
        return $this->belongsTo('App\Category', 'category_id');
    }
}
<?php
namespace App;

use EloquentCache\Database\Eloquent\CacheModel;

class Category extends CacheModel
{
    protected $cacheTags = ['category'];
    protected $fillable = [
        'title',
        'description',
    ];
}

Author

Alexander Tarkhov

License

This project is licensed under the MIT License - see the LICENSE file for details.