devituz / laravel-cachable
Simple and dynamic caching trait for Laravel models (Redis compatible)
v1.2.6
2025-10-24 10:36 UTC
Requires
- php: ^8.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
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();