DEV Community

PostSrc
PostSrc

Posted on • Originally published at postsrc.com on

Deleting Laravel Redis Queue Jobs

Deleting Laravel Redis Queue Jobs

There are several ways to delete Laravel Redis queue jobs and below are the available options.

Option 1 - Laravel Command

The first way to clear a Redis queue is to use the artisan queue clear:command and this is the easiest you can do. Just open up the terminal and type the command below.

php artisan queue:clear [connection] [queue]
Enter fullscreen mode Exit fullscreen mode

This command also works with other queue types such as a database.

Option 2 - Redis CLI

The second way is to use the Redis command and you can access it by typing it below.

redis-cli
Enter fullscreen mode Exit fullscreen mode

once you are in Redis CLI, just run the command below.

FLUSHDB
Enter fullscreen mode Exit fullscreen mode

This will clear all of your Redis cached.

Option 3 - Laravel Facade

Thirdly, If you want to use Laravel facade then you can create a route closure or console command to run the Redis command.

use Redis;

Redis::command('flushdb');
Enter fullscreen mode Exit fullscreen mode

BONUS: If you want then you can make use of Laravel tinker.

php artisan tinker
Enter fullscreen mode Exit fullscreen mode

After that run the command the flushdb command by passing it to the method parameters.

\\Redis::command(‘flushdb’);
Enter fullscreen mode Exit fullscreen mode

Above are some of the ways to clear out your Redis cache, there are other ways but those 3 ways above is the most common one and proven tested.

Thank you for reading the tutorial and I hope you managed to learn something. Do comment below to start the discussion of this topic. Cheers 🍻

This post was originally published at PostSrc 👑 🚀. If you like this kind of tutorial, I would really appreciate it if you give it a visit.

Top comments (0)