iazaran/smart-cache
Drop-in replacement for Laravel’s Cache facade that automatically compresses and chunks large values, deduplicates unchanged writes, self-heals corrupted entries, and performs cost-aware eviction. Works with existing code (PHP 8.1+, Laravel 8–13).
SimpleCache and Illuminate\Contracts\Cache\Repository), requiring zero code changes for basic usage. This aligns perfectly with Laravel’s dependency injection and facade patterns.repository()) maintains flexibility for edge cases.composer require with no mandatory configuration. Defaults are production-ready, though publishing the config file unlocks fine-tuning (e.g., adjusting compression thresholds or enabling encryption).Cache::get(), remember(), put()) work unchanged. The package does not override core Laravel contracts but extends them, avoiding breaking changes.ext-zlib and ext-json for full optimization (compression, serialization). These are standard in most PHP environments but should be validated in CI/CD pipelines.put() operations.memory_limit) may require tuning for datasets >100K items.LockProvider implementation. File-based caching may lack advanced features like atomic locks or jitter.asyncSwr() requires Laravel’s queue system, adding complexity to deployments without workers.single_flight)?lazy_loading enabled, and is memory_limit sufficient?LockProvider for advanced features.asyncSwr() or background refreshes. Ensure workers are sized to handle regeneration loads.ext-zlib and ext-json are enabled in the deployment environment.Cache:: with SmartCache:: in non-critical modules (e.g., admin panels, reports).swr(), stale()) for non-critical data.Cache:: in high-impact modules (e.g., checkout, search).Cache:: references to SmartCache:: (or alias SmartCache to Cache in config/app.php).php artisan optimize:clear to refresh service providers.rememberIf(), swr()) are opt-in.Cache facade will not automatically use SmartCache. Explicitly replace Cache:: or use SmartCache::repository() for bypass.vendor:publish --tag=smart-cache-config) to customize thresholds (e.g., compression size) or enable features like encryption.ide-helper generation needed.php artisan smart-cache:audit to identify large/unoptimized entries.php artisan smart-cache:bench --profile=api-json).composer.json and run composer install.php artisan optimize:clear).config/smart-cache.php (e.g., disable compression for binary data).remember(), swr()).config/smart-cache.php (e.g., compression thresholds, chunking behavior).CacheHit, CacheMissed) for observability.php artisan smart-cache:status for health checks.php artisan smart-cache:audit.php artisan smart-cache:bench.memory_limit is sufficient for large datasets. EnableHow can I help you explore Laravel packages today?