List Magento cache keys in Redis CLI
View and understand Magento cache key patterns using Redis CLI commands.
Fresh bytes every Thursday. No spam, ever. Unsubscribe anytime.
Join 9,000+ developers and get three free video lessons every week.
Let's look at how Magento organizes its cache keys in Redis.
First, let's open up terminal and connect to it using the Redis CLI command:
If you are using Docker, be sure to connect to the container first and then execute the redis-cli command. Ex:
docker-compose exec redis redis-cli
Once connected to Redis, we can view entries using the KEYS
keyword.
Use a simple asterisk to return all entries in the Redis database:
Or, we can specify a certain pattern, such as the zc
prefix to return all entries related to Magento.
You’ll see something like this:
Let's break down how Magento names and structures these cache entries.
First, all Magento cache entries start with zc:
, which stands for "Zend Cache", the name of Magento’s underlying cache framework.
After the zc:
prefix, entries will have one of two types:
k:
means "key", and contains the actual cached contentti:
means "tags index", and stores cache tags that group related cache items together
The final part of each entry (69d_EAV_ATTRIBUTE
) looks a bit random, but consists of:
- A cache ID prefix that’s unique to your specific Magento instance. In this case, it is
69d
. - Then an underscore, followed by the actual cache identifier, like
EAV_ATTRIBUTE
orCAT_C_3
.
The exact entries you'll see depend on your specific Magento setup and what's currently cached, but they'll always follow these same patterns.
When you're done exploring, just type exit
and hit Enter to exit the Redis CLI.