Starfish.Redis 1.0.8

dotnet add package Starfish.Redis --version 1.0.8
                    
NuGet\Install-Package Starfish.Redis -Version 1.0.8
                    
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="Starfish.Redis" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Starfish.Redis" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Starfish.Redis" />
                    
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 Starfish.Redis --version 1.0.8
                    
#r "nuget: Starfish.Redis, 1.0.8"
                    
#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 Starfish.Redis@1.0.8
                    
#: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=Starfish.Redis&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Starfish.Redis&version=1.0.8
                    
Install as a Cake Tool

Microsoft.Extensions.Configuration.Redis

Redis configuration provider implementation for Microsoft.Extensions.Configuration.

Redis key/value

The Redis configuration provider requires a hash key in Redis. The following example shows how to store json settings to Redis hash structure.

Note: The Redis configuration provider does not support nested values.

Origin json data

{
  "Settings": {
    "Server": "localhost",
    "Database": "master",
    "Ports": [ "1433", "1434", "1435" ]
  }
}

The Redis key/value pair structure is shown below.

Redis key: appsettings

Redis value:

Settings:Server = localhost
Settings:Database = master
Settings:Ports:0 = 1433
Settings:Ports:1 = 1434
Settings:Ports:2 = 1435

How to?

The following example shows how to read application settings from the Redis.

Install NuGet package

NuGet package:

Package Version Downloads
Starfish.Redis Nuget Nuget
Install-Package Starfish.Redis
dotnet add package Starfish.Redis
<PackageReference Include="Starfish.Redis" Version="$(StarfishVersion)" />

Add Redis configuration provider

using System;
using Microsoft.Extensions.Configuration;

class Program
{
    static void Main()
    {
        IConfiguration config = new ConfigurationBuilder()
            .AddRedis("127.0.0.1:6379,ssl=False,allowAdmin=True,abortConnect=False,defaultDatabase=0,connectTimeout=500,connectRetry=3", "appsettings")
            .Build();

        // Get a configuration section
        IConfigurationSection section = config.GetSection("Settings");

        // Read simple values
        Console.WriteLine($"Server: {section["Server"]}");
        Console.WriteLine($"Database: {section["Database"]}");

        // Read a collection
        Console.WriteLine("Ports: ");
        IConfigurationSection ports = section.GetSection("Ports");

        foreach (IConfigurationSection child in ports.GetChildren())
        {
            Console.WriteLine(child.Value);
        }
    }
}

Enable Redis Keyspace Notifications

The Redis configuration provider uses Redis keyspace notifications to invalidate the cache when the configuration changes. The Redis keyspace notifications are disabled by default. To enable the Redis keyspace notifications, set the notify-keyspace-events configuration option in the Redis configuration file to AKE.

  1. Open terminal and run redis-cli.
  2. Check the current configuration value use CONFIG GET notify-keyspace-events.
  3. Set the notify-keyspace-events configuration option to AKE use CONFIG SET notify-keyspace-events AKE.
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 is compatible.  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
1.0.8 146 7/6/2025
1.0.6 160 6/2/2024
1.0.5 108 5/10/2024
1.0.3 190 3/6/2024
1.0.2 188 12/23/2023
1.0.1 185 12/22/2023
1.0.0 159 12/21/2023