Skip to content

Laravel Eloquent model auto caching.

License

Notifications You must be signed in to change notification settings

tarkhov/eloquent-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eloquent cache

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.