Copied!
Laravel
Redis

Redis Queue in Laravel — Setup, Configuration & Example

redis-queue-in-laravel
Shahroz Javed
Nov 04, 2025 . 24 views

Table Of Contents

 

Redis is a fast in-memory data store that integrates perfectly with Laravel queues. Using Redis as your queue driver makes job processing faster and more scalable compared to database queues.

🚀 Laravel’s queue system allows you to defer time-consuming tasks like sending emails or processing uploads — Redis helps you handle them in real time.

1. Install Predis for Laravel

Laravel supports two Redis clients — phpredis (extension) and predis (package). We’ll use predis since it’s easier to install and works without PHP extensions.

composer require predis/predis
    

2. Configure Redis in Laravel

Open your .env file and set the following values:

REDIS_CLIENT=predis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
    

Now update your config/database.php file to use the environment variable:

'client' => env('REDIS_CLIENT', 'predis'),
    

Also add the Redis alias in config/app.php under aliases:

'Redis' => Illuminate\Support\Facades\Redis::class,
    

3. Configure Queue Connection

Laravel allows multiple queue drivers — database, Redis, SQS, Beanstalk, etc. To use Redis, set the following in your .env:

QUEUE_CONNECTION=redis
    

Once configured, Laravel will automatically push and pull jobs from your Redis server.

4. Create a Job

Use the artisan command to create a new queued job:

php artisan make:job SendMail
    

The generated job class implements the ShouldQueue interface by default.

Example:

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SendMail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle()
    {
        \Log::info('Email sent successfully!');
    }
}
    

5. Dispatching the Job

You can now dispatch your queued job anywhere in your app — controller, service, or command:

dispatch(new SendMail());
    

When dispatched, the job will be pushed into your Redis queue.

6. Processing the Queue

Run the Laravel queue worker to start processing jobs:

php artisan queue:work
    
⚙️ The worker listens for new jobs from Redis and executes them instantly.

7. Testing Redis Commands

You can still interact with Redis directly using Laravel’s Redis facade:

Redis::set('foo', 'bar');
Redis::get('foo');
    

8. Verify Queue Jobs in Redis

You can open redis-cli and check your queue data:

KEYS *
LRANGE queues:default 0 -1
    

9. Advantages of Redis Queue

 

Redis Queue is an essential upgrade for any production Laravel app. It handles background jobs efficiently and scales perfectly with modern workloads.

21 Shares

Similar Posts