Download the PHP package hishabee/laravel-query-cache without Composer
On this page you can find all versions of the php package hishabee/laravel-query-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hishabee/laravel-query-cache
More information about hishabee/laravel-query-cache
Files in hishabee/laravel-query-cache
Package laravel-query-cache
Short Description Smart SQL query caching for Laravel with tag-based invalidation
License MIT
Informations about the package laravel-query-cache
Laravel Query Cache
Smart SQL query caching for Laravel with tag-based invalidation and precise cache clearing.
Features
- Automatic query caching with intelligent tag-based invalidation
- Support for explicit query-level cache control
- Smart cache invalidation based on WHERE clauses
- Configurable caching strategy (all queries or manual)
- Works with Laravel 7.0 and above
- Compatible with Redis and Memcached
- Cache stampede prevention
Installation
The package will automatically register its service provider.
Configuration
Publish the configuration file:
Add these variables to your .env
file:
Basic Usage
How It Works
Tag-Based Caching
The package uses a sophisticated tagging system to enable precise cache invalidation:
-
Table-Level Tags
- Multiple Conditions
Cache Invalidation
When a table is updated, the package intelligently invalidates only relevant cached queries:
Cache Keys
Cache keys are generated based on the full query including bindings:
Smart Cache Duration
You can set cache duration at multiple levels:
-
Global Default (in config)
- Per Query
Advanced Usage
Working with Complex Queries
Manual Cache Control
Debugging Cache Behavior
Enable debug mode in your .env:
This will log:
- Cache hits/misses
- Generated tags
- Cache invalidations
Example log output:
Performance Considerations
-
Cache Store
- Redis (recommended) or Memcached required for tag support
- File cache driver doesn't support tags
-
Cache Duration
- Shorter durations for frequently updated tables
- Longer durations for static/reference data
- Excluded Tables
- Add frequently updated tables to
excluded_tables
in config - Consider excluding tables with sensitive data
- Add frequently updated tables to
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License. See LICENSE.md for details.
All versions of laravel-query-cache with dependencies
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0
greenlion/php-sql-parser Version ^4.5