dv0vd / laravel-redis-stale-refs-cleaner
Laravel console command to purge stale Redis cache references
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dv0vd/laravel-redis-stale-refs-cleaner
Requires
- php: >=7.4
- illuminate/cache: >=6.0
- illuminate/console: >=6.0
- illuminate/support: >=6.0
Suggests
- ext-redis: Required for phpredis client
- predis/predis: Required for predis client
This package is not auto-updated.
Last update: 2025-11-28 06:54:44 UTC
README
A lightweight Laravel console command that helps you keep your Redis cache clean and efficient by purging stale (broken) cache references.
In Laravel 6–8, there was no built-in way to safely clean up Redis sets containing references to keys that no longer exist. Laravel 9 introduced a helper command (php artisan cache:prune-stale-tags), but older versions require a custom solution — this package fills that gap.
Why This Package Exists
When using Redis to store reference sets (e.g., standard_ref for temporary caches or forever_ref for permanent caches), over time some referenced keys may expire or be deleted.
This can lead to stale references, which in turn can cause:
- Wasted memory in Redis
- Inaccurate cache statistics
- Unexpected behavior when iterating over cache sets
Without a safe cleanup process, these stale references accumulate, slowly “clogging” your cache and potentially affecting application performance.
This command automates the cleanup, safely removing references to keys that no longer exist, keeping your Redis cache tidy and efficient.
Features
- Safe purging of stale cache references from Redis sets
- Works with both phpredis (
ext-redis) andpredis/predisclients - Fully compatible with Laravel 6+
- Chunked processing for large sets to avoid memory issues
- Logs progress and provides a summary of purged keys
- Easy to run via Artisan console
Installation
composer require dv0vd/laravel-redis-stale-refs-cleaner
Usage
- Run the command:
php artisan redis:purge-stale-refs
- Sit back, relax, and enjoy your clean Redis!