Memoize Tagged Cache Reads in Laravel | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Memoize Tagged Cache Reads in Laravel with Cache::memo()-&gt;tags()

   [Laravel](https://www.msaied.com/public/articles?category=laravel) [Tips &amp; Tricks](https://www.msaied.com/public/articles?category=tips-tricks) 

 Memoize Tagged Cache Reads in Laravel with Cache::memo()-&gt;tags()
====================================================================

 Laravel 13.33 extends Cache::memo() to support cache tags. Learn how to memoize tagged cache reads, how writes and flushes are handled, and when to reach for this pattern in your applications.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 25 Sep 2026 · Updated 26 Sep 2026 · 3 min read

ShareCopy linkCopied

 ![Memoize Tagged Cache Reads in Laravel with Cache::memo()->tags()](https://cdn.msaied.com/703/21176fd1d525c82ff97cf9834cd084c1.png) 

  On this page +1. [Memoize Tagged Cache Reads in Laravel](#memoize-tagged-cache-reads-in-laravel)
2. [Why This Matters](#why-this-matters)
3. [Memoizing a Tagged Lookup](#memoizing-a-tagged-lookup)
4. [The Old Workaround](#the-old-workaround)
5. [How Writes and Flushes Work](#how-writes-and-flushes-work)
6. [When to Use It](#when-to-use-it)
7. [Key Takeaways](#key-takeaways)

 Memoize Tagged Cache Reads in Laravel
-------------------------------------

Laravel's memoized cache driver, `Cache::memo()`, reads a key from your cache store once per request and then serves it from memory for every subsequent call. Starting in **Laravel 13.33**, it also supports cache tags, so you can now call `Cache::memo()->tags()` to memoize tagged values without any extra workarounds.

### Why This Matters

Consider a permission lookup. Every `can()` call and every `@can` directive in a Blade view can trigger a cache read. Without memoization, each one round-trips to your cache store (Redis, Memcached, etc.). With `Cache::memo()->tags()`, only the first call in a request hits the store; the rest are served from memory.

### Memoizing a Tagged Lookup

Using the memoized tagged cache looks identical to a normal tagged cache call — just prepend `Cache::memo()`:

```php
use Illuminate\Support\Facades\Cache;

public function getPermissions(User $user): Collection
{
    return Cache::memo()
        ->tags(['permissions', "user:{$user->id}"])
        ->remember(
            "permissions:{$user->id}",
            now()->addHour(),
            fn () => $this->loadPermissionsFromDatabase($user)
        );
}

```

The first call reads from the cache store (or executes the closure on a miss). Every subsequent call with the same tags and key within the same request returns the in-memory copy.

### The Old Workaround

Before tagged memoization existed, developers had to nest a tagged cache call inside an `array` store manually:

```php
return Cache::store('array')->tags('permission_cache')->rememberForever(
    $cacheKey,
    fn () => Cache::tags($this->cacheTags($user))->remember(
        $cacheKey,
        config('auth.permissions.default_cache_time'),
        fn () => $this->loadPermissionsFromDatabase($user)
    )
);

```

`Cache::memo()->tags()` replaces this pattern cleanly.

### How Writes and Flushes Work

Any method that mutates a value writes through to the underlying tagged cache store **and** drops the memoized copy of that key, so the next read fetches a fresh value:

```php
$cache = Cache::memo()->tags(['permissions']);

$cache->get('permissions:1');           // Reads from the cache store
$cache->get('permissions:1');           // Reads from memory

$cache->put('permissions:1', $updated); // Writes to the store, clears memoized copy
$cache->get('permissions:1');           // Reads from the cache store again

```

This behaviour applies to `put()`, `putMany()`, `add()`, `increment()`, `decrement()`, `forever()`, `touch()`, and `forget()`. Calling `flush()` flushes the tags in the store and clears all memoized values for those tags.

### When to Use It

The memoized cache reflects what the **current request** has already read. A queue worker or another request changing the value mid-flight will not be visible to the current request until the memoized copy is invalidated.

**Good candidates:**

- Permission sets
- Application settings
- Feature flags
- Any value that is stable for the duration of a single request or job

**Avoid for:**

- Counters updated by multiple processes
- Anything another process may change while the current request is still running

Memoized values reset at the start of each new request or queued job, so long-running workers do not accumulate stale data between jobs.

### Key Takeaways

- `Cache::memo()->tags()` is available from **Laravel 13.33** onwards.
- The first tagged read per request hits the store; subsequent reads come from memory.
- Write operations (`put`, `forget`, `flush`, etc.) invalidate the in-memory copy automatically.
- Use it for stable, per-request values like permissions and settings; avoid it for frequently mutated shared state.
- It replaces the verbose `array` store nesting workaround that was previously required.

---

*Source: [Memoize Tagged Cache Reads in Laravel — Laravel News](https://laravel-news.com/laravel-tagged-memoized-cache)*

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [Cache](https://www.msaied.com/public/articles?search=Cache)
- [Performance](https://www.msaied.com/public/articles?search=Performance)
- [Laravel 13](https://www.msaied.com/public/articles?search=Laravel%2013)
- [Memoization](https://www.msaied.com/public/articles?search=Memoization)

 Frequently asked questions 
---------------------------

  What version of Laravel introduced tag support for Cache::memo()?Tag support for Cache::memo() was introduced in Laravel 13.33, allowing you to call Cache::memo()-&gt;tags() to memoize tagged cache reads within a request.

   Does Cache::memo()-&gt;tags() stay consistent if another process updates the cache mid-request?No. The memoized cache holds what the current request has already read. If another request or queue worker updates the value, the current request will not see the change until the memoized copy is invalidated by a write operation or the request ends.

   Which write methods invalidate the memoized copy when using Cache::memo()-&gt;tags()?The following methods write to the underlying store and drop the memoized copy: put(), putMany(), add(), increment(), decrement(), forever(), touch(), and forget(). Calling flush() also clears all memoized values for the affected tags.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleJetBrains Air: Run AI Coding Agents Directly in JetBrains IDEs](https://www.msaied.com/public/articles/jetbrains-air-run-ai-coding-agents-directly-in-jetbrains-ides) [Next articleLivewire v3 Islands, Lazy Components, and Deferred Loading in Practice](https://www.msaied.com/public/articles/livewire-v3-islands-lazy-components-and-deferred-loading-in-practice-4)  

   On this page
-------------

1. [Memoize Tagged Cache Reads in Laravel](#memoize-tagged-cache-reads-in-laravel)
2. [Why This Matters](#why-this-matters)
3. [Memoizing a Tagged Lookup](#memoizing-a-tagged-lookup)
4. [The Old Workaround](#the-old-workaround)
5. [How Writes and Flushes Work](#how-writes-and-flushes-work)
6. [When to Use It](#when-to-use-it)
7. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
