Download the PHP package skaisser/laravel-cache-cascade without Composer

On this page you can find all versions of the php package skaisser/laravel-cache-cascade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-cache-cascade

Laravel Cache Cascade

Tests Code Coverage Laravel

Never lose your cached data again. Laravel Cache Cascade provides bulletproof caching with automatic fallback through multiple storage layers. When Redis goes down, your app keeps running. When files get corrupted, data loads from the database. When the database is empty, seeders run automatically.

๐Ÿš€ Perfect for: SaaS settings, CMS content, API responses, feature flags, and any rarely-changing data that must always be available.

Why This Package Exists

Ever had Redis crash and take your app down because all your cached settings disappeared? Or struggled with cache invalidation when your database updates? Laravel's built-in cache is great, but it has limitations:

Laravel Cache Cascade solves these problems by creating a resilient caching system that automatically falls back through multiple storage layers and keeps them in sync.

Laravel Cache vs Cache Cascade

Feature Laravel Cache Cache Cascade
Fallback Mechanism โŒ None โœ… Cache โ†’ File โ†’ Database โ†’ Seeder
Automatic Invalidation โŒ Manual โœ… Model observers auto-refresh
Persistent Storage โŒ Memory only โœ… File + Memory
Database Sync โŒ Manual โœ… Automatic on update
Visitor Isolation โŒ Not built-in โœ… Optional per-key
Auto-seeding โŒ Manual โœ… Runs seeders automatically
Zero-config Models โŒ Requires setup โœ… Just add trait

Features

Installation

Install the package via Composer:

Configuration

Publish the configuration file:

This will create a config/cache-cascade.php file where you can customize the package settings.

Key Configuration Options

Usage

Basic Usage

Remember Pattern

Visitor Isolation

Enable visitor-specific caching to prevent data leakage between users:

Working with Models

The package can automatically load data from Eloquent models and seed if empty:

How It Works

Fallback Chain

When you request data, the package tries each storage layer in order:

  1. Cache Layer: Fast in-memory storage (Redis/Memcached)
  2. File Layer: Persistent file storage for rarely-changing data
  3. Database Layer: Load from Eloquent models
  4. Auto-seeding: Run seeders if no data exists

File Storage Format

Files are stored in PHP format by default:

Automatic Model Detection

The package intelligently detects models based on the cache key:

Cache Invalidation

One of the most important features is automatic cache invalidation when database data changes. The package provides multiple ways to handle this:

Manual Invalidation

Automatic Model Invalidation

Use the CascadeInvalidation trait in your Eloquent models for automatic cache invalidation:

Now when you update the model, the cache is automatically refreshed:

Invalidation Events

The trait automatically invalidates cache on:

Manual Model Refresh

Advanced Usage

For advanced features like custom storage drivers, performance optimization, multi-tenant support, and more, see the Advanced Usage Guide.

Quick Examples

Custom Transformations

Skip Database Layer

Cache Tags (Redis/Memcached only)

Comprehensive Examples

Real-World Usage Patterns

E-commerce Settings

Multi-tenant SaaS Application

CMS Content Management

API Response Caching

Feature Flags & Configuration

Laravel Integration

Artisan Commands

The package provides several Artisan commands:

Integration with Laravel Commands

cache:clear

By default, running php artisan cache:clear will also clear all cascade cache. You can disable this:

config:cache

Dynamic cascade files are excluded from config:cache by default. If you need to check which files would be cached:

Logging & Debugging

Enable detailed logging to debug cache behavior:

Or configure in the config file:

View runtime statistics:

Example log output:

Real-World Use Cases

๐Ÿข SaaS Applications

Problem: Your app stores tenant settings, feature flags, and subscription plans in cache. When Redis restarts, all tenants experience errors.

Solution: Cache Cascade ensures settings persist in files and auto-reload from database:

๐Ÿ“ฐ Content Management Systems

Problem: Your CMS caches articles, menus, and widgets. Cache invalidation is a nightmare when editors update content.

Solution: Use the trait for automatic invalidation:

๐ŸŒ API Gateway / Microservices

Problem: You cache API responses but need fallback when the cache server is unreachable.

Solution: Cache with file backup for critical endpoints:

๐ŸŽ›๏ธ Feature Flags & Configuration

Problem: Feature flags must always be available but can change dynamically.

Solution: Database-backed cache with instant updates:

๐Ÿช E-commerce Settings

Problem: Payment gateways, shipping rates, and tax rules must never fail to load.

Solution: Multi-layer protection with auto-seeding:

Testing

Testing Your Code with CacheCascade::fake()

The package provides a powerful fake implementation for easy testing:

Available test assertions:

See Testing Documentation for comprehensive examples.

Running Package Tests

Run the test suite:

Run tests with code coverage:

Test Coverage

The package maintains 90.13% code coverage with comprehensive tests for:

Performance

Benchmarks

Cache Cascade adds minimal overhead while providing maximum reliability:

Operation Native Cache Cache Cascade Overhead
Cache Hit 0.02ms 0.03ms +50%
Cache Miss (File Hit) 5ms 0.5ms -90%
Cache Miss (DB Hit) 5ms 5.2ms +4%
Write Operation 0.1ms 0.8ms +700%*

*Write operations update all layers for reliability

Optimization Tips

  1. Use appropriate TTLs - Longer TTLs reduce database hits
  2. Enable visitor isolation selectively - Only for user-specific data
  3. Use file storage for rarely-changing data - Config, settings, etc.
  4. Batch operations when possible - Reduce write overhead

Security

See Security Best Practices for detailed guidelines.

Documentation

Changelog

Please see CHANGELOG for recent changes.

Contributing

Contributions are welcome! Please see Contributing Guide for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-cache-cascade with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/cache Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/filesystem Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package skaisser/laravel-cache-cascade contains the following files

Loading the files please wait ....