Download the PHP package iazaran/smart-cache without Composer
On this page you can find all versions of the php package iazaran/smart-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iazaran/smart-cache
More information about iazaran/smart-cache
Files in iazaran/smart-cache
Package smart-cache
Short Description Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.
License MIT
Homepage https://github.com/iazaran/smart-cache
Rated 5.00 based on 1 reviews
Informations about the package smart-cache
Laravel SmartCache - Intelligent Caching Optimization Package
Laravel SmartCache is a powerful caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.
Perfect for Laravel developers looking to optimize cache performance, reduce memory usage, and improve application speed with intelligent data compression and cache management.
๐ Features
- ๐ Auto-detects large cache payloads - Automatically identifies when optimization is needed
- ๐ฆ Compresses data before caching - Reduces storage requirements with gzip compression
- ๐งฉ Chunks large arrays or objects into manageable parts for better performance
- ๐ง Intelligent serialization - Advanced data serialization techniques
- โป๏ธ Seamless retrieval and reconstruction - Transparent data recovery
- โ๏ธ Extensible strategy pattern for custom optimizations
- ๐ก๏ธ Optional fallback for incompatible drivers
- ๐ Laravel-style helper function support
- ๐ฏ Redis and file cache driver optimization
- ๐ Performance monitoring and cache statistics
๐ฆ Installation
Install the package via Composer:
Requirements: Laravel 8+ is supported. Tested with Redis and file cache drivers.
โ๏ธ Configuration
After installation, publish the config file:
The config file allows you to define thresholds, compression strategies, chunk sizes, and enabled features.
๐งช Usage
Basic Usage with SmartCache Facade
Use SmartCache
just like Laravel's Cache
facade:
Helper Function Usage
Or use the global helper function, similar to Laravel's cache()
helper:
Dependency Injection
Or inject it into your services:
๐ง Optimization Strategies
SmartCache includes several cache optimization strategies that intelligently optimize your data:
๐ฏ Strategy Selection & Priority
SmartCache automatically selects the best optimization strategy for your data:
-
Chunking Strategy (Priority 1)
- Applied to large arrays/collections with many items
- Splits data into manageable chunks for better performance
- Best for: Large datasets, API response arrays, database result sets
-
Compression Strategy (Priority 2)
- Applied to large strings, arrays, and objects
- Uses gzip compression to reduce cache size
- Best for: Text data, serialized objects, repetitive content
- No Optimization (Default)
- Small data stays unchanged for optimal performance
- No overhead for data that doesn't benefit from optimization
๐ง Intelligent Strategy Application
Each strategy evaluates the original data independently to determine if it should apply:
- Data Type Matching: Chunking only applies to arrays/collections, compression works on all types
- Size Thresholds: Each strategy has configurable size thresholds
- Driver Compatibility: Strategies respect cache driver limitations
- Performance Optimization: Only one strategy is applied per value (no chaining overhead)
๐ ๏ธ Built-in Strategies
- Compression: Uses gzip compression with configurable levels (1-9)
- Chunking: Splits large arrays into configurable chunk sizes
- Encoding: Safe serialization for different cache drivers
- Driver-Aware: Automatically adapts to your cache driver capabilities
โ๏ธ Extensible Architecture
Create custom strategies by implementing SmartCache\Contracts\OptimizationStrategy
:
๐ Example: Large Dataset Caching
๐ฏ Strategy Selection Examples
๐งฐ Artisan Commands
SmartCache provides powerful Artisan commands for cache management and monitoring:
๐ Status Command
View SmartCache usage and configuration details:
What --force
shows:
- โ Orphaned key detection - Find SmartCache-related keys that aren't properly tracked
- ๐ Missing key validation - Identify managed keys that no longer exist in cache
- ๐งน Cache health insights - Get suggestions for cleanup and optimization
๐๏ธ Clear Command
Flexible cache clearing with precise control:
When to use --force
:
- ๐ง Cleanup orphaned keys - Remove leftover SmartCache chunks or metadata
- ๐ฏ Clear non-managed keys - Remove regular Laravel cache keys when needed
- ๐งน Deep cleanup - Comprehensive cache maintenance and optimization
๐ฏ Use Cases
- Large API response caching - Optimize storage of external API data
- Database query result caching - Cache complex query results efficiently
- Session data optimization - Reduce session storage requirements
- File-based cache optimization - Improve file cache performance
- Redis memory optimization - Reduce Redis memory usage
- High-traffic applications - Improve performance under load
๐ Performance Benefits
- Up to 70% reduction in cache storage size
- Faster cache retrieval for large datasets
- Reduced memory usage in Redis and other drivers
- Improved application response times
- Better resource utilization
๐ง Supported Cache Drivers
- โ Redis - Full feature support with compression and chunking
- โ File Cache - Optimized file-based caching
- โ Database - Database cache driver optimization
- โ Array - In-memory cache optimization
- โ ๏ธ Memcached - Basic support (limited chunking)
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Reporting bugs
- Suggesting features
- Submitting pull requests
- Code style guidelines
๐ License
Laravel SmartCache is open-sourced software licensed under the MIT license.
๐ Links
- GitHub Repository: https://github.com/iazaran/smart-cache
- Packagist Package: https://packagist.org/packages/iazaran/smart-cache
- Documentation: https://iazaran.github.io/smart-cache/
Built with โค๏ธ for developers who care about Laravel performance optimization and efficient caching strategies.
Keywords: Laravel caching, PHP cache optimization, Redis optimization, cache compression, Laravel performance, data chunking, cache management, Laravel package
All versions of smart-cache with dependencies
illuminate/support Version >=8.0
illuminate/cache Version >=8.0
illuminate/console Version >=8.0
illuminate/contracts Version >=8.0