- What is rapidez/laravel-multi-cache used for?
- Laravel Multi Cache lets you register named caches that combine multiple Laravel cache stores, so different parts of your application can use different drivers through one familiar cache API. It is useful when you want one logical cache to span stores, such as a fast local store plus a persistent shared store. You still configure the underlying Laravel cache stores normally.
- How do I install rapidez/laravel-multi-cache?
- Install it with Composer by running composer require rapidez/laravel-multi-cache. Laravel package auto-discovery should register the service provider; if your application disables discovery, register the provider manually. Then publish or edit the package configuration and define your named multi-cache stores.
- How do I configure multiple cache stores with Laravel Multi Cache?
- Define named caches in the package configuration and map each one to the underlying Laravel cache stores you want it to use. After that, select the named cache with Laravel's normal cache store syntax or the package's documented API. Keep your underlying store definitions in Laravel's cache configuration as usual.
- Can Laravel Multi Cache read and write to multiple stores at once?
- Yes. A configured multi-cache can read from and write to its underlying stores using Laravel's familiar cache methods. The exact read order and write behavior depend on the package configuration, so check the documentation for how you want misses and writes handled across stores. This lets one logical cache operation span multiple drivers.
- How does Laravel Multi Cache handle TTL and expiration?
- TTLs are passed through the familiar Laravel cache API, such as put and remember, and are applied to the configured stores. Expiration behavior therefore follows Laravel's cache repository rules for each underlying driver. If stores have different eviction policies, account for that in your design.
- Which Laravel versions and cache drivers does Laravel Multi Cache support?
- The package targets Laravel's cache system and works with Laravel cache stores rather than replacing them. Exact Laravel version constraints and tested drivers are listed in the package's composer.json and documentation. Verify your Laravel version and driver compatibility before adopting it.
- Is Laravel Multi Cache safe for production?
- It can be used in production when the underlying stores are reliable and you understand the trade-offs of writing to multiple backends. Multi-store writes can add latency and partial-failure scenarios, so monitor cache operations and decide how strict consistency needs to be. For critical data, keep a database source of truth rather than relying on cache alone.
- How do I test Laravel Multi Cache in my application?
- Use Laravel's normal testing tools and configure array or fake cache stores for the underlying drivers. Then assert that your named multi-cache reads and writes behave as expected, including TTL and fallback behavior. Avoid hitting real Redis or Memcached instances in unit tests.
- What are alternatives to Laravel Multi Cache?
- Laravel already lets you define multiple cache stores and choose one explicitly with the cache store API. Laravel Multi Cache is for grouping stores behind one named cache when you need read and write behavior across them. Alternatives include custom cache repositories or application-level logic that calls several stores directly.
- How do I keep Laravel Multi Cache up to date?
- Check Packagist and the package repository for releases, changelogs, and Laravel compatibility updates. Because it integrates with Laravel's cache contracts, retest after Laravel major upgrades and cache driver changes. Pin a compatible version in Composer and review release notes before upgrading.