Skip to content

Commit

Permalink
Updated all references and namespaces to RedisKit
Browse files Browse the repository at this point in the history
  • Loading branch information
melittleman committed Feb 6, 2024
1 parent d085fb6 commit cf19447
Show file tree
Hide file tree
Showing 55 changed files with 110 additions and 110 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# NRedisKit
# RedisKit
> A .NET Standard 2.1 helper library for common Redis client functionality. This project is very much still a work in progress.
This package aims to build upon [NRedisStack](https://github.com/redis/NRedisStack) and provide all the functionality needed to get up and running with a new project utilizing Redis as fast as possible. With **NRedisKit** you can add multiple named Redis connections within the Dependency Injection container _(beneficial in hybrid environments where Redis server setups could be different e.g. persistent vs non-persistent)_, then configure each of these connections with features such as .NET Data Protection keys persistence, an `ITicketStore` implementation to store large Claims Principals from your application's authentication cookies _(very useful within Blazor Server applications where no HTTP Context is available)_, individual health checks to each Redis server, message consumer and producer implementations to make working with Redis Streams more simple as well as many other helpful methods and extensions for working with the [RedisJSON](https://redis.io/docs/data-types/json) and [RediSearch](https://github.com/RediSearch/RediSearch) modules.
This package aims to build upon [NRedisStack](https://github.com/redis/NRedisStack) and provide all the functionality needed to get up and running with a new project utilizing Redis as fast as possible. With **RedisKit** you can add multiple named Redis connections within the Dependency Injection container _(beneficial in hybrid environments where Redis server setups could be different e.g. persistent vs non-persistent)_, then configure each of these connections with features such as .NET Data Protection keys persistence, an `ITicketStore` implementation to store large Claims Principals from your application's authentication cookies _(very useful within Blazor Server applications where no HTTP Context is available)_, individual health checks to each Redis server, message consumer and producer implementations to make working with Redis Streams more simple as well as many other helpful methods and extensions for working with the [RedisJSON](https://redis.io/docs/data-types/json) and [RediSearch](https://github.com/RediSearch/RediSearch) modules.

[![Build & Test](https://github.com/melittleman/NRedisKit/actions/workflows/build-test.yml/badge.svg)](https://github.com/melittleman/NRedisKit/actions/workflows/build-test.yml)
[![Build & Test](https://github.com/melittleman/RedisKit/actions/workflows/build-test.yml/badge.svg)](https://github.com/melittleman/RedisKit/actions/workflows/build-test.yml)

## Contents
- [Getting Started](#getting-started)
Expand All @@ -23,18 +23,18 @@ This package aims to build upon [NRedisStack](https://github.com/redis/NRedisSta
To get started with this library, you will first need to download and install either the [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) or Microsoft [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) which comes bundled with the SDK.

## Repository Structure
- **.github** - Files needed by GitHub are contained in the `.github` directory. For example; the `workflows` directory contains any _Build_, _Test_ or _Package_ configurations needed by **GitHub** [**Actions**](https://github.com/melittleman/NRedisKit/actions).
- **.github** - Files needed by GitHub are contained in the `.github` directory. For example; the `workflows` directory contains any _Build_, _Test_ or _Package_ configurations needed by **GitHub** [**Actions**](https://github.com/melittleman/RedisKit/actions).
- **src** - The _Source_ directory contains all the source code for the library.
- **test** - Contains all unit and integration tests relating to the **src** directory. These tests are implemented in [XUnit](https://xunit.net/) and can be run using the ```dotnet test``` CLI. These tests will also be run as part of the [Build & Test](https://github.com/melittleman/NRedisKit/actions/workflows/build-test.yml) workflow in GitHub Actions.
- **test** - Contains all unit and integration tests relating to the **src** directory. These tests are implemented in [XUnit](https://xunit.net/) and can be run using the ```dotnet test``` CLI. These tests will also be run as part of the [Build & Test](https://github.com/melittleman/RedisKit/actions/workflows/build-test.yml) workflow in GitHub Actions.

## Usage
Once you have installed the desired version of **NRedisKit** you can configure this during service registration to be used by an application in the following ways.
Once you have installed the desired version of **RedisKit** you can configure this during service registration to be used by an application in the following ways.

### Adding A Named Connection
You can add a named Redis connection to the Dependency Injection container and configure it by passing in an `Action` of `RedisConnectionOptions`.

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services.AddRedisConnection("cloud-cache", options =>
{
Expand All @@ -52,8 +52,8 @@ For example: `redis0:6379,redis1:6380,allowAdmin=true,ssl=false`

This can then be used later anywhere in the application via the Transient `IRedisClientFactory` that retrieves named Redis connections and creates the wrapping client.
```csharp
using NRedisKit;
using NRedisKit.DependencyInjection.Abstractions;
using RedisKit;
using RedisKit.DependencyInjection.Abstractions;

private readonly RedisClient _redis;

Expand All @@ -70,7 +70,7 @@ public async Task DoSomethingAsync()

If only a single Redis connection is being used within the application, this can then easily be retrieved directly from DI, rather than going via the factory.
```csharp
using NRedisKit;
using RedisKit;

private readonly RedisClient _redis;

Expand All @@ -87,8 +87,8 @@ public Task<T> GetSomethingAsync()

You can continue to use a connection in exactly the same ways that you would otherwise use [NRedisStack](https://github.com/redis/NRedisStack) or [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) directly.
```csharp
using NRedisKit;
using NRedisKit.DependencyInjection.Abstractions;
using RedisKit;
using RedisKit.DependencyInjection.Abstractions;

using NRedisStack;
using NRedisStack.RedisStackCommands;
Expand Down Expand Up @@ -121,7 +121,7 @@ The main benefit of configuring these named connections is to be able to connect
For example; a caching instance that does not have persistence or high availability enabled, and therefore reduces costs. And a Messaging instance, where both persistence and AOF writing may be needed.

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services.AddRedisConnection("enterprise-cache", options =>
{
Expand All @@ -143,7 +143,7 @@ The return type of `IServiceCollection.AddRedisConnection()` is a new instance o
For example, to add the .NET Data Protection middleware to the application that utilizes your named Redis connection:

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services
.AddRedisConnection("elasticache", options...)
Expand All @@ -154,7 +154,7 @@ services
The `RedisClient` is also able to help abstract Redis JSON document usage within the application. You can use your own custom JSON converters for (de)serialization by configuring it in the following way.

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services.ConfigureRedisJson(options =>
{
Expand All @@ -164,7 +164,7 @@ services.ConfigureRedisJson(options =>

Use the `RedisClient` in the same way as you would with any of the other built in Redis data types and it will use the configured JSON converters.
```csharp
using NRedisKit;
using RedisKit;

private readonly RedisClient _redis;

Expand All @@ -187,7 +187,7 @@ In order to get started simply chain either one or both of the methods below dur
> **Note**: These do not need to be chained to the same connection. For example you could _Consume_ messages from an internal Redis server and then _Produce_ these out to an entirely different public server.
```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services
.AddRedisConnection("message-broker", options...)
Expand All @@ -201,7 +201,7 @@ services
You can then request these abstractions from the Dependency Injection container and use them to produce or consume messages.

```csharp
using NRedisKit.Messaging.Abstractions;
using RedisKit.Messaging.Abstractions;

private readonly IMessageConsumer<MyMessage> _consumer;
private readonly IMessageProducer<MyMessage> _producer;
Expand Down Expand Up @@ -234,7 +234,7 @@ public Task ProduceSomethingAsync(MyMessage message)
The .NET Data Protection providers can be configured to use your named Redis connection and save the keys under a specified location like the following:

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services
.AddRedisConnection("redis-persistent", options...)
Expand All @@ -252,8 +252,8 @@ authentication sessions, and removes the reliance on browsers storing very large
> **Note**: You MUST ensure that both [JSON document](#json-documents) storage and [Data Protection](#data-protection) has been configured for this to work correctly.
```csharp
using NRedisKit.DependencyInjection.Extensions;
using NRedisKit.Json.Converters;
using RedisKit.DependencyInjection.Extensions;
using RedisKit.Json.Converters;

services
.AddRedisConnection("redis-persistent", options...)
Expand All @@ -269,7 +269,7 @@ services
You can configure the built in .NET Health Check framework to test connectivity to your named Redis connection as part of it's configured Health Checks.

```csharp
using NRedisKit.DependencyInjection.Extensions;
using RedisKit.DependencyInjection.Extensions;

services
.AddRedisConnection("redis-server", options...)
Expand Down
4 changes: 2 additions & 2 deletions NRedisKit.sln → RedisKit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9686F443-E07
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5C12C701-9BB2-48FC-A835-5176A592D149}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NRedisKit", "src\NRedisKit.csproj", "{34AEEB8C-DF91-4566-8D12-744A4F30FA20}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RedisKit", "src\RedisKit.csproj", "{34AEEB8C-DF91-4566-8D12-744A4F30FA20}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NRedisKit.UnitTest", "test\UnitTest\NRedisKit.UnitTest.csproj", "{C9B983E8-E79C-4A57-963D-6194DFE4371F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RedisKit.UnitTest", "test\UnitTest\RedisKit.UnitTest.csproj", "{C9B983E8-E79C-4A57-963D-6194DFE4371F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion src/Abstractions/IHashEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.Abstractions;
namespace RedisKit.Abstractions;

public interface IHashEntry
{
Expand Down
2 changes: 1 addition & 1 deletion src/Abstractions/IRedisContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.Abstractions;
namespace RedisKit.Abstractions;

/// <summary>
/// <para>The Redis connection context.</para>
Expand Down
2 changes: 1 addition & 1 deletion src/Abstractions/ISortedSetEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.Abstractions;
namespace RedisKit.Abstractions;

public interface ISortedSetEntry
{
Expand Down
2 changes: 1 addition & 1 deletion src/Abstractions/ITaggedEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.Abstractions;
namespace RedisKit.Abstractions;

public interface ITaggedEntry
{
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/RedisTicketStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using NRedisStack;
using NRedisStack.RedisStackCommands;

namespace NRedisKit.Authentication;
namespace RedisKit.Authentication;

/// <summary>
/// A custom <see cref="AuthenticationTicket"/> storage implementation of <see cref="ITicketStore"/> using
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.DependencyInjection.Abstractions;
namespace RedisKit.DependencyInjection.Abstractions;

public interface IRedisClientFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;

namespace NRedisKit.DependencyInjection.Abstractions;
namespace RedisKit.DependencyInjection.Abstractions;

/// <summary>
/// A fluent helper when building Redis connections that
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Concurrent;

namespace NRedisKit.DependencyInjection.Abstractions;
namespace RedisKit.DependencyInjection.Abstractions;

/// <summary>
/// A singleton container around multiple pooled Redis connections.
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/DefaultRedisClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Options;

namespace NRedisKit.DependencyInjection;
namespace RedisKit.DependencyInjection;

internal sealed record DefaultRedisClientFactory : IRedisClientFactory
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/DefaultRedisConnectionBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;

namespace NRedisKit.DependencyInjection;
namespace RedisKit.DependencyInjection;

/// <inheritdoc />
internal sealed record DefaultRedisConnectionBuilder : IRedisConnectionBuilder
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/DefaultRedisConnectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;

namespace NRedisKit.DependencyInjection;
namespace RedisKit.DependencyInjection;

/// <inheritdoc />
internal sealed record DefaultRedisConnectionProvider : IRedisConnectionProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
using OpenTelemetry.Trace;
using OpenTelemetry.Instrumentation.StackExchangeRedis;

using NRedisKit.Diagnostics;
using NRedisKit.Authentication;
using NRedisKit.Messaging;
using NRedisKit.Messaging.Constants;
using NRedisKit.Messaging.Abstractions;
using NRedisKit.Json.Converters;

namespace NRedisKit.DependencyInjection.Extensions;
using RedisKit.Diagnostics;
using RedisKit.Authentication;
using RedisKit.Messaging;
using RedisKit.Messaging.Constants;
using RedisKit.Messaging.Abstractions;
using RedisKit.Json.Converters;

namespace RedisKit.DependencyInjection.Extensions;

public static class RedisConnectionBuilderExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace NRedisKit.DependencyInjection.Extensions;
namespace RedisKit.DependencyInjection.Extensions;

public static class ServiceCollectionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.DependencyInjection.Options;
namespace RedisKit.DependencyInjection.Options;

public sealed record RedisAuthenticationTicketOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Options/RedisConnectionOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.DependencyInjection.Options;
namespace RedisKit.DependencyInjection.Options;

public sealed record RedisConnectionOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.DependencyInjection.Options;
namespace RedisKit.DependencyInjection.Options;

public sealed record RedisDataProtectionOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Options/RedisJsonOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace NRedisKit.DependencyInjection.Options;
namespace RedisKit.DependencyInjection.Options;

public sealed record RedisJsonOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Options/RedisMessagingOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.DependencyInjection.Options;
namespace RedisKit.DependencyInjection.Options;

// TODO: We may eventually need to look at creating specific options
// betwee Producers and Consumers as currently they both use the same IOptions
Expand Down
2 changes: 1 addition & 1 deletion src/Diagnostics/RedisHealthCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace NRedisKit.Diagnostics;
namespace RedisKit.Diagnostics;

/// <inheritdoc />
internal sealed record RedisHealthCheck : IHealthCheck
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/ConfigurationOptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.RegularExpressions;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

internal static class ConfigurationOptionsExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/DocumentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using NRedisStack.Search;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class DocumentExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/GuidExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class GuidExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/HashEntryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using System.Reflection;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class HashEntryExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/NameValueExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq;
using System.Reflection;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class NameValueExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/RedisValueExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Globalization;
using System.Text.Json;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

internal static class RedisValueExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/SortedSetEntryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class SortedSetEntryExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/StreamEntryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class StreamEntryExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace NRedisKit.Extensions;
namespace RedisKit.Extensions;

public static class StringExtensions
{
Expand Down
Loading

0 comments on commit cf19447

Please sign in to comment.