- What does suitmedia/laravel-cacheable actually do?
- It is a Laravel package that decorates your repositories so their Eloquent queries and model reads are served from cache, cutting repeated database hits on read-heavy endpoints. You keep writing normal repository code and the package layers cache handling around those calls. Integration is deliberately lightweight with minimal configuration required.
- How do I install suitmedia/laravel-cacheable in a Laravel app?
- Install it with Composer using composer require suitmedia/laravel-cacheable. Laravel package auto-discovery registers the service provider, so manual registration is normally not required. If the package ships a config file, publish it and review the cache store and TTL settings before deploying. Check that your runtime meets the 1.12.x platform floor, which drops PHP 7.4 and requires PHP 8.x.
- Does laravel-cacheable support Laravel 11 and PHP 8.3?
- Yes. Version 1.12.0 adds Laravel 11 and PHP 8.3 to the declared support matrix and extends CI coverage to match. The release is a compatibility and maintenance update rather than a feature release. There is no indication of new runtime capability, changed public API surface, or altered extension points.
- Can I still use laravel-cacheable on PHP 7.4 or older Laravel versions?
- Not on 1.12.x. PHP 7.4 support was formally dropped, so any service, CI runner, or developer workstation still pinned to 7.4 must stay on 1.11.x, which will receive no future patches. Treat the PHP floor change as effectively a breaking change for your own upgrade planning even though the package shipped it as a minor version bump.
- How does laravel-cacheable cache Eloquent models and repository queries?
- Caching happens at the repository layer: you decorate repositories so read operations are answered from the cache instead of hitting the database on every call. Common model operations flow through the same wrapper, so typical reads benefit without you rewriting query code. The release notes do not enumerate the internal coupling to Eloquent hooks, so review the source if deep framework integration matters to you.
- Does laravel-cacheable work with Redis, Memcached, or the file cache driver?
- The package targets Laravel's standard caching layer, so it should follow whatever cache store your application is configured to use, including Redis, Memcached, database, or file. Verify against your actual driver rather than assuming, since the release notes do not document per-driver behavior. Test read, write, and flush paths under your production store before relying on it.
- How do I invalidate or clear the cache when a model is updated?
- The package handles caching for common model operations, but the exact invalidation rules are not spelled out in the 1.12.0 notes, so check the README for the flush and invalidation API. Until you have verified the behavior, keep a fallback in write paths, such as short TTLs or explicit cache clearing for critical records. Confirm the invalidation strategy with tests covering create, update, and delete flows.
- How much of my repository code do I need to change to use it?
- Because the package works as a decorator, you wrap your existing repositories rather than rewriting query logic, which keeps the change surface small. Confirm your repository contracts and interfaces are compatible with the decorator pattern before rolling it out across the codebase. A sensible approach is to enable it on one read-heavy repository first, then measure the hit rate and query reduction.
- Is suitmedia/laravel-cacheable production-ready and what are the main risks?
- The technical assessment rates overall risk as low to moderate: the maintainer actively tracks Laravel's supported-version cadence, the package is small, and integration is low friction. The main concerns are the PHP 7.4 drop and a vaguely worded dependency update that could hide transitive constraint changes you have not verified. Pin the version, run your full test suite after upgrading, and check your root composer.lock for conflicts.
- What are the alternatives to laravel-cacheable for caching Eloquent queries?
- You can write your own repository decorator around Laravel's Cache facade, use remember() on individual queries, or adopt a broader response or query caching package depending on where you want the cache boundary. This package's value is a prebuilt, maintained decorator with minimal configuration rather than novel caching capability. If you only need a handful of cached queries, rolling your own decorator is a reasonable and lower-dependency option.