Yardios.RedisQueue 0.4.1

dotnet add package Yardios.RedisQueue --version 0.4.1
                    
NuGet\Install-Package Yardios.RedisQueue -Version 0.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yardios.RedisQueue" Version="0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Yardios.RedisQueue" Version="0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Yardios.RedisQueue" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Yardios.RedisQueue --version 0.4.1
                    
#r "nuget: Yardios.RedisQueue, 0.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Yardios.RedisQueue@0.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Yardios.RedisQueue&version=0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=Yardios.RedisQueue&version=0.4.1
                    
Install as a Cake Tool

Yardios.RedisQueue

Yardios.RedisQueue is a Redis-backed queue system for .NET 8+, inspired by Laravel's queue system. Easily enqueue jobs into Redis and process them using background workers.

Publish NuGet Package NuGet Downloads


✨ Features

  • Queue any IJob into Redis
  • Process jobs asynchronously with background workers
  • Dependency injection & configuration support
  • Retry logic & failure handling
  • Delayed job support
  • Specify queue names per job
  • Inspired by Laravel's queue system

📦 Installation

Add via CLI:

dotnet add package Yardios.RedisQueue

Or via .csproj:

<PackageReference Include="Yardios.RedisQueue" Version="0.4.1" />

🛠️ Usage

1️⃣ Register the Redis Queue

In your Program.cs:

var builder = WebApplication.CreateBuilder(args);

// Add RedisQueue using IConfiguration (appsettings.json)
builder.Services.AddRedisQueue(builder.Configuration);

var app = builder.Build();
app.Run();

In your appsettings.json:

{
  "Redis": {
    "ConnectionString": "localhost:6379"
  },
  "QueueProcessorOptions": {
    "QueueNames": [ "default", "emails" ],
    "JobRetryOptions": {
      "MaxRetries": {
        "Yardios.API.Application.Jobs.SendTeamInvite": 3
      },
      "FailUntilAttempt": {
        "Yardios.API.Application.Jobs.SendTeamInvite": 2
      }
    }
  },
  "QueueWorkerOptions": {
    "DelayMilliseconds": 1000
  }
}

2️⃣ Create a Job

Implement the IJob interface:

public class SendEmailJob : IJob
{
    public string Email { get; set; }
    public string Message { get; set; }

    public async Task HandleAsync(IServiceProvider services, CancellationToken cancellationToken)
    {
        var emailService = services.GetRequiredService<IEmailService>();
        await emailService.SendAsync(Email, Message);
    }
}

3️⃣ Enqueue a Job (with Queue Name and Delay)

You can specify the queue name and an optional delay when enqueuing jobs:

await _queue.EnqueueAsync(new SendEmailJob
{
    Email = "future@example.com",
    Message = "This is a delayed job!"
}, queueName: "emails", delay: TimeSpan.FromSeconds(30));
  • queueName (optional): The Redis queue to push the job onto. Must match one of the QueueNames in appsettings.json.
  • delay (optional): A TimeSpan specifying how long to delay before processing the job.

Example without delay:

await _queue.EnqueueAsync(new SendEmailJob
{
    Email = "test@example.com",
    Message = "Hello!"
}, queueName: "default");

4️⃣ Dependency Injection Best Practices

✅ Always inject the IQueue interface into your services — never inject the concrete RedisQueue class directly. This allows for better abstraction, future flexibility, and proper dependency resolution by the DI container.

For example, in your services:

public class TeamService : ITeamService
{
    private readonly IQueue _queue;

    public TeamService(IQueue queue)
    {
        _queue = queue;
    }

    // Use _queue.EnqueueAsync(...) in your methods
}

✅ Avoid injecting the RedisQueue class directly:

// ❌ Do not do this
public class TeamService
{
    public TeamService(RedisQueue queue) { }
}

This will cause runtime errors because RedisQueue is registered under the interface IQueue in the service collection.


🛠️ Configuration

  • Redis connection info is specified in appsettings.json under Redis:ConnectionString.
  • QueueProcessorOptions allows setting queue names.
  • QueueJobOptions allows specifying per-job settings like FailUntilAttempt and MaxRetries.

Example appsettings.json:

{
  "Redis": {
  "ConnectionString": "localhost:6379"
  },
  "QueueProcessorOptions": {
    "QueueNames": [ "default", "emails" ],
    "JobRetryOptions": {
      "MaxRetries": {
        "Yardios.API.Application.Jobs.SendTeamInvite": 3
      },
      "FailUntilAttempt": {
        "Yardios.API.Application.Jobs.SendTeamInvite": 2
      }
    }
  },
  "QueueWorkerOptions": {
    "DelayMilliseconds": 5000
  }
}

💡 Inspired By

  • Laravel Queue System

📄 License

MIT License


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.1 188 6/2/2025
0.4.0 152 5/29/2025
0.3.0 145 5/28/2025
0.2.0 142 5/28/2025
0.1.0 148 5/28/2025