Memoize Tagged Cache Reads in Laravel | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Memoize Tagged Cache Reads in Laravel with Cache::memo()-&gt;tags()        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 with Cache::memo()->tags()](https://cdn.msaied.com/703/21176fd1d525c82ff97cf9834cd084c1.png)

 [  Laravel ](https://msaied.com/articles?category=laravel) [  Tips &amp; Tricks ](https://msaied.com/articles?category=tips-tricks)  #Laravel   #Cache   #Performance   #Laravel 13   #Memoization  

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

     25 Sep 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)  Mohamed Said  

       Table of contents

1. [  01   Memoize Tagged Cache Reads in Laravel  ](#memoize-tagged-cache-reads-in-laravel)
2. [  02   Why This Matters  ](#why-this-matters)
3. [  03   Memoizing a Tagged Lookup  ](#memoizing-a-tagged-lookup)
4. [  04   The Old Workaround  ](#the-old-workaround)
5. [  05   How Writes and Flushes Work  ](#how-writes-and-flushes-work)
6. [  06   When to Use It  ](#when-to-use-it)
7. [  07   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)*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fmemoize-tagged-cache-reads-in-laravel-with-cachememo-tags&text=Memoize+Tagged+Cache+Reads+in+Laravel+with+Cache%3A%3Amemo%28%29-%3Etags%28%29) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Fmemoize-tagged-cache-reads-in-laravel-with-cachememo-tags) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  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. 

      Q02  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. 

      Q03  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. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![Decide with Jev: Build a Laravel AI Content Preflight Checker That Returns a Probability](https://cdn.msaied.com/701/916a0dd2b427c6335395d6d2684524ab.png) Laravel AI Jev TypeSafe 

### Decide with Jev: Build a Laravel AI Content Preflight Checker That Returns a Probability

Jev is a TypeSafe AI model that returns a probability score instead of text. Learn how Harris Raftopoulos uses...

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

 25 Sep 2026     4 min read  

  Read    

 ](https://msaied.com/articles/decide-with-jev-build-a-laravel-ai-content-preflight-checker-that-returns-a-probability) [ ![Filament v4 Migrating from v3: Breaking Changes and Refactor Patterns](https://cdn.msaied.com/700/85cddaf32751d756924869323a845563.png) filament laravel upgrade 

### Filament v4 Migrating from v3: Breaking Changes and Refactor Patterns

A practical, opinionated guide to the most impactful breaking changes when upgrading Filament v3 to v4, with c...

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

 25 Sep 2026     4 min read  

  Read    

 ](https://msaied.com/articles/filament-v4-migrating-from-v3-breaking-changes-and-refactor-patterns-1) [ ![Livewire v3 Islands, Lazy Components, and Deferred Loading in Practice](https://cdn.msaied.com/699/2667012bbe680cb54d99e4596e396547.png) livewire laravel performance 

### Livewire v3 Islands, Lazy Components, and Deferred Loading in Practice

Lazy components and deferred loading in Livewire v3 let you ship fast initial pages and hydrate expensive UI o...

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

 25 Sep 2026     1 min read  

  Read    

 ](https://msaied.com/articles/livewire-v3-islands-lazy-components-and-deferred-loading-in-practice-4) 

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

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
