- How does spiritix/lada-cache work without requiring manual cache tags or query modifications?
- Lada Cache integrates at the Laravel database connection level using `DB::extend()`, intercepting all Eloquent and Query Builder queries. It generates cache keys automatically based on SQL structure and invalidates only affected rows or tables when data changes, so no manual tags or query alterations are needed.
- Will lada-cache work with Laravel 13 and PHP 8.3?
- Yes, Lada Cache 6.x is fully compatible with Laravel 13 and PHP 8.3. The package was rewritten specifically for these versions, addressing performance and stability improvements over older releases.
- How does granular invalidation work for row-level changes?
- When a row is updated or deleted, Lada Cache uses the model’s primary key to invalidate only the cached queries for that specific row. If the primary key is composite or non-standard, it falls back to table-level invalidation to ensure consistency.
- Can I exclude specific tables or models from caching?
- Absolutely. Lada Cache allows fine-grained control via the config file. You can disable caching globally or specify which tables/models to include or exclude, making it flexible for mixed workloads.
- Does lada-cache support Redis clusters or failover configurations?
- Yes, Lada Cache leverages Laravel’s Redis cache driver, which natively supports clusters and failover configurations. You can use the same Redis setup you already have for caching, ensuring high availability and scalability.
- Will complex queries (e.g., subqueries, joins) be cached properly?
- Lada Cache handles most standard queries well, but complex queries like nested subqueries or `UNION` operations may not be fully supported for row-level invalidation. In such cases, it defaults to table-level invalidation to maintain correctness.
- How do I monitor cache performance (hits, misses, invalidations) in production?
- Lada Cache integrates with Laravel Debugbar, providing real-time stats on cache hits, misses, and invalidations. For production monitoring, you can also log these metrics or use Laravel’s built-in logging to track performance.
- What happens if Redis goes down? Does the app fall back to the database?
- If Redis is unavailable, Lada Cache will automatically bypass caching and execute queries directly against the database. This ensures your application remains functional, though performance may degrade temporarily.
- Can I use lada-cache with custom query builders or third-party ORMs?
- Lada Cache primarily targets Laravel’s Eloquent and Query Builder. Custom query builders or third-party ORMs may bypass the caching layer, requiring manual integration or exclusion in the config to maintain consistency.
- How do I test cache behavior, especially invalidation and edge cases?
- Lada Cache includes comprehensive test coverage and supports mocking Redis for unit tests. For integration testing, use Laravel’s testing tools to simulate writes and verify cache invalidation. The Debugbar integration also helps debug edge cases during development.