Skip to content

CoreSystem.Redis

Redis infrastructure and distributed locking for .NET 8, 9 and 10.

CoreSystem.Redis is a lightweight Redis infrastructure library built on StackExchange.Redis. It provides reusable components for connection management and distributed synchronization so cloud-native applications and other CoreSystem modules can coordinate reliably across nodes.

NuGet Downloads License .NET


Features

  • Redis connection factory (IRedisConnectionFactory)
  • Distributed lock provider (IDistributedLockProvider)
  • Configurable lock options (RedisLockOptions)
  • Dependency Injection integration

Installation

dotnet add package CoreSystem.Redis

Quick Start

builder.Services.AddCoreRedis(options =>
{
    // Configure RedisLockOptions here.
});

public sealed class OrderService(IDistributedLockProvider lockProvider)
{
    public async Task ProcessAsync(CancellationToken ct)
    {
        await using var handle = await lockProvider.AcquireAsync("order-42", ct);
        // Only one instance executes this block at a time.
    }
}

Endpoints and connection settings are supplied through the IRedisConnectionFactory.Create delegate (for example options.EndPoints.Add("localhost:6379")); at least one endpoint is required. Consult the package README for the wire-up details.


Relationship with CoreSystem.Memory

CoreSystem.Memory CoreSystem.Redis
Scope Single process Multiple nodes
Delivery In-process semaphores Redis distributed locks
Package CoreSystem.Memory CoreSystem.Redis

Contributing

Issues, discussions and pull requests are welcome.