As you know Redis could have several databases, in my laravel setup ive defined 3 of them and using 2 at least
'0' (default)
'1' (cache)
'2' (queue)
Thats what ive set in config/database.php
Furthermore, due to certain need I clear all cache using flushall()
method:
@Cache::flush();
@Redis::flushall();
However, it also clears the queue jobs which is not what I want. So is there a way to only flush database 0 and database 1 and not database 2?
2
Answers
You may use select and flushdb commands together to flush only selected database.
The following will select the database
1
first and flush only1
.It is going to execute following commands in redis;
redis-cli -n [database number] flushdb