Boost Laravel performance using the new memoized cache driver in Laravel 12.9. Learn how it works, when to use it, and see real-world examples for faster caching.

Introduction
With Laravel 12.9, a new experimental memoized cache driver was introduced to supercharge application performance. If you've ever wished your Laravel app could skip repetitive cache reads and deliver lightning-fast responses, the memoized driver is the answer.
In this article, we’ll explore:
- What is the memoized cache driver?
- How it works under the hood
- Real-world use cases
- Configuration and code examples
- Performance considerations
What is the Memoized Cache Driver in Laravel?
The memoized cache driver stores data in memory during a single request lifecycle, meaning it doesn’t hit the underlying cache (e.g., Redis or file) again if the same cache key is requested multiple times within the same request.
It’s not a persistent cache—it’s an in-request memory layer on top of your actual cache store.
Why Use It?
Laravel developers often call cache()->get('some_key')
multiple times in a request. If the key was already fetched, why fetch it again from Redis or the file system? The memoized driver remembers previous cache calls and returns them instantly.
Real-World Use Cases
Use Case 1: Avoid Repeated Cache Fetches in API Controllers
With the memoized cache driver, the second get()
is served from memory, not Redis.
Use Case 2: Performance Boost in Blade Views with Shared Data
In complex Blade layouts, the same cache key might be accessed multiple times. Memoization ensures Laravel doesn’t re-fetch it from Redis or files.
Use Case 3: Complex Service Classes or Event Listeners
In service classes where multiple methods rely on the same cache key:
How to Enable Memoized Cache in Laravel 12.9
Laravel 12.9 introduced the memoize()
method on the cache repository.
Here’s how to use it:
Chaining with Other Drivers
You can wrap any cache driver with memoization:
You don’t need to change your default cache store—just memoize when needed.
Full Example: Memoized Caching in a Controller
Memoized vs Persistent Cache
Feature | Memoized Cache | Redis/File Cache |
---|---|---|
Persistence | Only for current request | Persistent across requests |
Speed | Fastest (in-memory) | Fast but requires IO/network |
Use case | Repeated same-key access | Global/shared caching |
Scope | Per-request | Application-wide |
When Not to Use Memoized Cache?
- Don’t use it alone for long-term caching. It resets every request.
- It won't improve performance across requests—only within a single request.
- Avoid relying on it for data consistency or cross-request availability.
Performance Tip: Combine Both Caches
You can combine persistent cache with memoized wrapper:
This caches settings
in Redis but avoids repeated Redis calls in the same request.
Conclusion
Laravel’s new memoized cache driver in v12.9 brings a powerful in-memory caching layer for performance optimization. While it's not a replacement for Redis or file caching, it eliminates redundant cache lookups during a request—saving time and resources.
Quick Benefits Recap:
- Increases performance by reducing cache calls
- Ideal for repeated
Cache::get()
calls - Easy to implement with
Cache::memoize()
- Works with any existing cache driver (Redis, file, etc.)
If you're searching for:
- How to use Laravel memoized cache
- Laravel cache performance tips
- Laravel 12.9 cache driver examples
- Memoize in Laravel
- In-memory caching in Laravel
Then this is the practical guide you need to improve caching speed in your Laravel 12+ applications.
Try It Now
Start memoizing your cache calls today and see measurable speed improvements in your app!