spatie/laravel-flexible-cache-polyfill
Larablocks Analysis
Compatibility
Trusted maintainerspatie/laravel-flexible-cache-polyfill works with Laravel 10 (latest release 0.1.0, Dec 2, 2025), which reached end of life on Feb 4, 2025: no more fixes, even for security.
- Trusted maintainer: spatie publishes 287 packages on Larablocks, with 204,800,870 downloads a month between them.
Recommendation checks
Use with careUse with care: meets 0 of 4 checks.
- Supports only Laravel 10, past end of life since Feb 4, 2025
- No release in the last 12 months (last: Dec 2, 2025)
- 40 downloads a month (needs 10,000)
- 1 GitHub star (needs 100)
State
Quiet- Last stable release: Dec 2, 2025.
- No releases in the last 12 months.
- First released: Dec 2, 2025.
- Monthly downloads: 40, about the same as six months ago.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require spatie/laravel-flexible-cache-polyfill |
|
| Latest Version: | 0.1.0 |
| PHP: | ^8.1 |
| Laravel: | 10 |
| License: | MIT |
| Last Updated: | Oct 22, 2026 |
| Links: | GitHub · Packagist |
Polyfill for Cache::flexible() in Laravel 10 and 11
This package provides a polyfill for the Cache::flexible() method, which was introduced in Laravel 11. It brings the stale while revalidating cache pattern to Laravel 10.
When using Cache::remember, some users may experience slow response times if the cached value has expired. The flexible method allows stale data to be served while the cached value is recalculated in the background after the response is sent, preventing slow response times for your users.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
composer require spatie/laravel-flexible-cache-polyfill
Usage
Using the Cache::flexible() facade:
$value = Cache::flexible('users', [5, 10], function () {
return DB::table('users')->get();
});
The first value (5) is the number of seconds the cache is considered "fresh". The second value (10) defines how long it can be served as stale data before recalculation is necessary.
- 0-5 seconds: Returns cached value immediately
- 5-10 seconds: Returns stale value, refreshes in background after response is sent
- After 10 seconds: Cache expired, recalculates immediately
Support for all stores is available:
$value = Cache::store('redis-2')->flexible(...);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Speed up a Laravel application by caching the entire response
Laravel SDK for the GorillaDash website GraphQL API with stale-while-revalidate...
Build Elasticsearch queries based of a query string
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 0.1.0 | ^8.1 | ^10.0 | MIT |
