| Install | |
|---|---|
composer require spiritix/lada-cache |
|
| Latest Version: | v6.1 |
| PHP: | ^8.3 |
A Redis-based, fully automated, and scalable query cache layer for Laravel.
Lada Cache 6.x - a focused rewrite for Laravel 12 / 13 and PHP 8.3, addressing many long-standing issues and adding new features.
| Laravel | PHP | Lada Cache |
|---|---|---|
| 5.1-5.6 | 5.6.4+ | 2.x |
| 5.7-5.8 | 7.1+ | 3.x |
| 6.x | 7.2+ | 4.x |
| 7.x | 7.2+ | 5.x |
| 8.x | 7.3+ | 5.x |
| 9.x-11.x | 8.0+ | 5.x |
| 12.x | 8.3+ | 6.x |
| 13.x | 8.3+ | 6.x |
Lada Cache integrates with Laravel’s database layer by registering a Lada-aware connection, which returns a custom query builder to intercept and cache SQL operations automatically.
Query lifecycle:
The result is automatic, consistent caching across all database operations.
Real-world gains range from 5% to 95%, depending on how many and how complex your queries are. Typical Laravel apps see ~10–30% faster responses and a significant drop in DB load.
Lada Cache provides automated, granular, distributed caching with transparent invalidation and scale-out via Redis.
Therefore, Lada Cache builds directly on top of Laravel Redis. If you need another backend, contributions are welcome.
Install via Composer:
composer require spiritix/lada-cache
Lada Cache registers itself automatically via Laravel Package Discovery.
Then, publish the config file:
php artisan vendor:publish --provider="Spiritix\LadaCache\LadaCacheServiceProvider"
Finally, ensure all your Eloquent models include the trait:
use Spiritix\LadaCache\Database\LadaCacheTrait;
class Car extends Model
{
use LadaCacheTrait;
}
💡 It’s best to add the trait in a shared
BaseModelclass that all models extend.
After publishing the configuration file (see Installation), you will find a comprehensive config file at config/lada-cache.php.
This file allows you to fine-tune cache behavior, such as:
The default configuration is already optimized for most Laravel applications, so you typically won’t need to modify it unless you want more granular control.
After installation, Lada Cache works automatically.
No code changes or caching calls are required - all database queries are transparently cached and invalidated.
You can control global behavior via .env:
LADA_CACHE_ACTIVE=true
LADA_CACHE_DEBUGBAR=true
# Flush all cached entries
php artisan lada-cache:flush
# Temporarily disable cache
php artisan lada-cache:disable
# Re-enable cache
php artisan lada-cache:enable
DB::connection('foo')) are only supported when using Lada’s connection integration. Models defining $connection work automatically.UNION/INTERSECT/advanced expressions may not be fully reflected for row-level tagging; invalidation falls back to table-level tags.DB::select(), DB::statement()) is not cached by design.Pull requests and issue reports are welcome!
master)Lada Cache is open-source software licensed under the MIT License.