Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis keys not shown while using Cache facade in Laravel

Tags:

php

redis

laravel

I'm using Laravel Cache facade, and the CACHE_DRIVER=redis. All data is saved in Redis successfully, but when I use redis-cli and run keys* there are not keys!

When using the command flushall in redis-cli it loads the data again from the database, so that means the keys are already stored in Redis.

like image 364
Faid Avatar asked Dec 07 '22 12:12

Faid


1 Answers

Redis has 16 databases indexed 0 - 15. The default database index is 0, so when you run redis commands without specifying the database index, you're only running commands against database index 0. However, as of Laravel 5.7, Laravel stores all the cache data in database index 1.

In order to see the keys in your cache database, you need to query database 1. You can either use the -n switch on the command line to specify the database index, or use the select command at the redis prompt to change the active database.

redis-cli -n 1 keys "*"

or

#> redis-cli
127.0.0.1:6379> select 1
127.0.0.1:6379[1]> keys *
like image 56
patricus Avatar answered Jan 01 '23 13:01

patricus