devituz/laravel-cachable

Simple and dynamic caching trait for Laravel models (Redis compatible)

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/devituz/laravel-cachable

v1.1.2 2025-10-17 19:44 UTC

This package is auto-updated.

Last update: 2025-10-17 19:44:42 UTC


README

LaravelCachable is a simplified, multi-language model caching trait that works with Redis. It automatically caches and purges model data on created, updated, and deleted events.

📦 Installation

composer require devituz/laravel-cachable

Add model

use Cachable;

Example code

$product = Product::find(1);

// 🔹 Save single record to cache
$product->cacheSingle();

// 🔹 Retrieve single record from cache
$cached = Product::getCached(1);

// 🔹 Retrieve all records from cache
$all = Product::allCached();

// 🔹 Clear cache for a record
$product->forgetCache();