Check if a specific cache tag exists

Viewed 1734

To check if a cache key exists, you can do this in Laravel:

use Cache;

if (Cache::has('key_name')) {
    // continue
}

Is there a way to do the same for tags?

// ! Pseudo code
if (Cache::hasTag('tag_name')) {
    // continue
}

Or, at least, to know whether there are any keys tagged with a specific tag?

// ! Pseudo code
if (Cache::tags('tag_name')->count() > 0) {
    // continue
}
0 Answers
Related