I have cached something with tags:
Cache::tags(['mytag'])->put('topmenu', $dataMenus);
Was just reading the docs, and i can check the cache for a key:
if(Cache::has('topmenu')) {
// ....
}
But how do I check the key AND the tags? I would think like this:
if(Cache::tags(['mytag'])->has('topmenu')) {
// ...
}
But I am not sure, what if the tags doesn't exist?
I had same problem.
I solved this problem.
$tag = 'mytag'; $key = 'topmenu';
$value = collect(Cache::tags($tag)->getTags()->flush())->first(fn($item) => $item === $key);
now you check use if condition value empty or not check.