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

tobz.nz's avatar

tobz.nz wrote a reply+100 XP

1mo ago

how to get all cache items by tag ?

I know this is an old thread, but thought I'd post this anyway - a Macro that does as you'd expect:

You can then get all the items with any combination of tags.

Cache::tags(['tag1', 'tag2', 'tag3'])->put('item1', 1);
Cache::tags(['tag1', 'tag4'])->put('item1', 2);
Cache::tags(['tag1', 'tag3'])->put('item1', 3);

Cache::tags(['tag1', 'tag2', 'tag3'])->getAll();
// item 1

Cache::tags(['tag1'])->getAll();
// item1, item 2, item 3

Cache::tags(['tag3'])->getAll();
// item 1, item 3