Score:1

Is there a way to fetch cache keys by a pattern or a cache tag

hk flag

I was trying to find if there is a way to fetch or count Drupal cache keys that match a pattern. I couldn't find a function in the CacheBackendInterface that does this.

The context is that I was trying to see if there is some way to show statistics around the different types of cache keys being used.

Alfred Armstrong avatar
cn flag
Because the cache is supposed to be a keystore, where you can only fetch items by their exact key (meaning it can be implemented using a wide range of different technologies), wildcard queries are not supported. Also cache entries are not guaranteed to be persistent, so stats may mislead. DB cache can be queried as you suggest, other cache mechanisms not necessarily. You'll have to write your own interface to whichever you are using.
hk flag
Thanks for the answer @AlfredArmstrong
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.