Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Chain Adapter

Chain Adapter Laravel Package

cache/chain-adapter

PSR-6 cache pool chain adapter that combines multiple cache pools (e.g., APCu + Redis) into a single CachePoolChain. Part of PHP-Cache, with optional features like tagging and hierarchy via shared docs. Install with composer and use with minimal setup.

View on GitHub
Deep Wiki
Context7

[READ-ONLY] Chain multiple PSR-6 Cache pools together for performance

Frequently asked questions about Chain Adapter
How do I integrate this package with Laravel’s Cache facade?
Register the chain as a new driver in `config/cache.php` under `drivers`. Use existing PSR-6 pools (e.g., Redis, APCu) as sub-pools in the chain. Laravel’s `Cache::tags()` will work seamlessly with the chain for grouped invalidation.
Does this work with Laravel 10 and PHP 8.1+?
The package adheres to PSR-6, which Laravel fully supports, but the last release was in 2022. Test thoroughly with PHP 8.1+ as some dependencies may lack updates. No known PHP 8.x incompatibilities exist yet, but monitor for deprecation warnings.
What’s the performance impact of chaining multiple caches (e.g., Redis → APCu)?
Latency increases slightly due to sequential fallback checks, but the chain avoids redundant writes. Benchmark your specific pools—Redis + APCu typically adds <5ms per request. Use `skip_on_failure` to optimize critical paths.
How does `skip_on_failure` work if all pools fail?
If `skip_on_failure` is `true`, the chain returns an empty cache (no data) on failure. There’s no built-in default fallback like a database cache; you’d need to implement custom logic (e.g., retry or log the error) for production-grade reliability.
Can I monitor cache hit/miss rates per pool in the chain?
The package doesn’t natively track per-pool metrics, but you can wrap each pool in a custom logger or use Laravel’s `CacheStoreEvent` listeners to log hits/misses. For advanced monitoring, extend the chain with a decorator pattern.
Will this break Laravel’s tag-based invalidation (e.g., `Cache::tags(['users'])->flush()`)?
No, the chain supports PSR-16 tags and integrates with Laravel’s `Cache::tags()`. However, if a non-tag-aware pool (e.g., `FileCachePool`) is in the chain, tagged invalidation will only work for pools that support tags.
Is the chain thread-safe for Laravel queues or Horizon jobs?
Yes, the chain is thread-safe as long as the underlying PSR-6 pools (Redis, APCu, etc.) are thread-safe. Laravel’s queue workers or Horizon jobs can use the chain without concurrency issues, assuming the pools handle parallel access properly.
What’s the best way to test this in a Laravel app before production?
Start with a non-critical feature (e.g., dashboard cache) using a simple chain (Redis → APCu). Test edge cases like pool failures, tag invalidation, and high concurrency. Use Laravel’s `cache:clear` and custom TTL logging to validate behavior.
Are there alternatives for multi-cache fallback in Laravel?
Laravel’s built-in `CacheManager` supports multiple drivers, but they’re not chained—you’d need manual logic for fallbacks. Other PSR-6 chain adapters (like `league/container-adapter`) exist, but this package is the most Laravel-native due to PSR-6 compliance.
How do I handle stale data if a primary cache (e.g., Redis) fails?
Use `skip_on_failure` to fall back to secondary pools (e.g., APCu). For critical data, implement a custom fallback (e.g., database cache) or retry logic. Monitor failures via Laravel’s `CacheStoreEvent` or a wrapper logger to alert on stale data risks.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky