Laravel Cached data in Redis

If you work with Laravel caching to store queries in the Redis database you may want to every now and then check how the keys are stored and if they are stored. Here is a quick command that gets this done

redis-cli -n 1 keys "*"

The thing you should realize here is that we specify which database to check. If you just use

redis-cli keys "*"

Redis will pick the first database index which is 0 not the one Laravel stores data in. You need the second index which is … 1 .

To get the value for a key you need to know they key and then do a

redis-cli -n 1 GET ""

The part laravel_database_laravel_cache:tag seems to be added for all tagged cache keys using tag and remember. This is followed by your chosen tag name and then key .

So if you would store with this code (part of it)

$blog-title = x;
$blog = Cache::tags("blog.{$blog-title}")->remember("blog.{$blog-title}", now()->addHours(12), function () use ($blog-title) {

you should be able to get the content using php artisan tinker and this command:


where the real blog title is the title of the blog stored.


You can of course also use a GUI like Red . It helps you to look up data in the index of your choice in a nice visual way. It can teach you a lot as it shows you what commands are executed as you click to check tags, keys, change index and so on.

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.