insomnicles/laracache

A trait for caching Laravel models

v0.0.9 2022-04-27 18:03 UTC

This package is auto-updated.

Last update: 2024-04-25 21:04:45 UTC


README

Latest Version on Packagist Total Downloads StyleCIBanner

A trait for accessing Laravel Eloquent models directly from Cache

Source code packagist.

Installation

Via Composer

$ composer require insomnicles/laracache

Usage

Make sure your app is connected to a Cache: memcache, redis, etc.

  • If you're using Sail in Laravel 8+, this is setup out of the box

Add the Cachable Trait to your Model; for example, for the User Model

	use Insomnicles\Laracache\Cachable.php

	class User {
		use Cachable;

	}

Use the Cached Model via Eloquent-like methods

	User::refreshCache();
	User::allInCache();

Change log

Please see the changelog for more information on what has changed recently.

License

MIT. Please see the license file for more information.