How to wildcard cache clear in Drupal 8? In Drupal 7, we used to be able to do this:

cache_clear_all('state:', 'cache', TRUE)


which would delete any cache bin entires that started with the string state: (matching cache IDs such as state:info and state:nebraska).

The change record at https://www.drupal.org/node/1272696 even notes this use case in the Drupal 7 example, but does not actually provide an example of how to replicate it in D8.

It seems that we're supposed to use cache tags, which seems like a more more expensive conversion considering the simple use case. I don't see any matching methods that would apply in CacheBackendInterface. Note, this is not about deleting all items in a cache bin, which is clearly covered by deleteAll().
Not sure why the existing answer was deleted, it was (almost) correct.

Wildcard cache clears was removed. It was extremely complicated to support in backends like redis and memcache, which have no wildcard support.

Cache tags is the replacement and it is not that complicated to use. You just pass along a list of strings as the 4th argument (a bit annoying that you have to set the default timestamp argument, a separate method would be nice):

\Drupal::cache('default')-&gt;set('state:info', $your_data, Cache::PERMANENT, 
['state']);


and then call:

\Drupal\Core\Cache\Cache::invalidateTags(array('state'));