Back

Laravel devs, did you know Cache::get accepts a closure as a fallback? 💡

It runs only if the key is missing
But it does not store the result in cache ❌

Use Cache::remember if you want to store it ✅
image

2

56

In response to @MrPunyapal

Why would you use the closure on Get, when Remember does the same thing and then sets the cache? I use Remember all over my apps.

1

29

  • No matching results...
  • Searching...

/ 1000

Poll Options

Sometimes caching done wia webhook. And there is no way around it so you wanna do fall back logic if it doesn't exists.

It can be logging and returning default value etc.

24