Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlCo2's avatar

Why this code make my cache Misses (pulse)

each time this code run, its make my pulse misses to increase for each Google Account I have in database, and I can't figure out what's wrong with it?

$setup = GoogleAccount::all()->map(function ($googleAccount) { $key = 'setup.'.$googleAccount->id.'.status'; return [ $googleAccount->email => Cache::has($key) ? Cache::get($key) : null ]; });

0 likes
1 reply
JussiMannisto's avatar

Please format your code blocks using three backtics:

```
// Your code goes here.
```

You're calling Cache::has($key), which checks if the key exists in cache. If it doesn't, you get a cache miss. You're not putting anything in the cache, at least in this code. I don't know if it's "wrong". It depends on what you're trying to do.

Please or to participate in this conversation.