Search by

kybdev / laravel-redis-read-cache

kybDev

Transparent Redis read-through caching for Laravel applications.

Package info

github.com/kybDev/laravel-redis-read-cache

pkg:composer/kybdev/laravel-redis-read-cache

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-10-08 07:54 UTC

This package is auto-updated.

Last update: 2026-10-08 07:54:51 UTC


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