kybdev / laravel-redis-read-cache
Transparent Redis read-through caching for Laravel applications.
Package info
github.com/kybDev/laravel-redis-read-cache
pkg:composer/kybdev/laravel-redis-read-cache
Requires
- php: ^8.2
- illuminate/console: ^10.0|^11.0|^12.0
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/redis: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Laravel package that provides a transparent Redis read-through cache for eligible database reads without changing controllers, models, queries, or application business logic.
Compatibility
- PHP 8.2 and 8.3
- Laravel 10, 11, and 12 (through the matching
illuminate/*components)
The package supports Laravel 10.0+ through 12.x. It requires PHP ^8.2.
The service provider is registered through Laravel package auto-discovery.
Features
- Global read-through interception at the Laravel database connection layer
- Environment-controlled activation via
REDIS_READ_CACHE_ENABLED - Uses the configured Laravel Redis connection
- Falls back safely to normal database reads when Redis is unavailable
- Includes a warm-up command for newly provisioned servers
Installation
composer require kybdev/laravel-redis-read-cache
If you want to publish the package config file, run:
php artisan vendor:publish --provider="KybDev\\RedisReadCache\\RedisReadCacheServiceProvider" --tag=redis-read-cache-config
Add the following environment variables:
REDIS_READ_CACHE_ENABLED=true REDIS_READ_CACHE_CONNECTION=cache REDIS_READ_CACHE_TTL=300 REDIS_READ_CACHE_PREFIX=redis_read_cache:
Usage
This package works transparently. Existing usage such as:
$units = Unit::where('active', 1)->get();
automatically uses Redis when enabled.
Warm-up command
php artisan redis:hot-runner php artisan redis:hot-runner --tables=units,systems --limit=500 --force
Packagist
This package is designed to be publishable to Packagist later as:
kybdev/laravel-redis-read-cache
License
MIT