eusonlito/laravel-database-cache
ModelObserver, eloquent.* events) for automatic invalidation, reducing manual cache management.DB::table() and Eloquent queries via a fluent interface (cache() method).cache table growth.)eloquent.* listeners.)/stats endpoints).cache() method on Eloquent queries:
User::where('active', true)->cache(300)->get(); // 5-minute TTL
php artisan vendor:publish --tag=database-cache-config..env:
DB_CACHE_TABLE=laravel_cache
DB_CACHE_TTL=600
User::observe(UserCacheObserver::class);
handleCacheInvalidation in observers for custom logic.cache()->remember() as a hybrid approach for complex queries.laravel/framework version constraints.REPLACE support).globalScopes don’t interfere with caching.Post::popular()->get()).User updates).cacheKey customization).redis-cli).cache table size (alert if >10MB).Cache::stats()).eloquent.* events.key column).DB::disableCache() to verify fallback behavior.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database downtime | All cached queries fail | Fallback to uncached queries (wrap in try-catch). |
| Cache table corruption | Stale/inconsistent data | Regular DB backups; monitor table health. |
| Event listener failures | Uninvalidated cache | Retry logic in observers; alert on failures. |
| Key collision | Overwritten cache entries | Use unique cacheKey for dynamic queries. |
| High cache churn | DB performance degradation | Implement TTL tiers (short/long cache). |
>100ms execution").with() relations).Cache::getHitRate()).whereRaw/join queries.How can I help you explore Laravel packages today?