func-redis 0.1.0-rc0003

This is a prerelease version of func-redis.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package func-redis --version 0.1.0-rc0003                
NuGet\Install-Package func-redis -Version 0.1.0-rc0003                
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="func-redis" Version="0.1.0-rc0003" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add func-redis --version 0.1.0-rc0003                
#r "nuget: func-redis, 0.1.0-rc0003"                
#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.
// Install func-redis as a Cake Addin
#addin nuget:?package=func-redis&version=0.1.0-rc0003&prerelease

// Install func-redis as a Cake Tool
#tool nuget:?package=func-redis&version=0.1.0-rc0003&prerelease                

Functional Redis

GitHub CI Quality Gate Status codecov NuGet NuGet Mutation testing badge

The Func.Redis project contains code that provide a service layer for interacting with Redis, a popular in-memory data structure store. The purpose of this code is to abstract and manage Redis operations, such as setting, getting, deleting, and renaming keys, as well as handling hash sets and Pub/Sub operations within Redis.

Purpose

The design of Func.Redis emphasizes a functional programming approach, ensuring that the code is both robust and flexible. Below are the key aspects that highlight the purpose and benefits of using Func.Redis in your .NET applications:

  • Abstraction: These classes and interfaces abstract the complexity of interacting with Redis, providing a clean and consistent API for the rest of the application.
  • Key Transformation: The key transformation functions allow for flexible key management, enabling the modification of keys before they are used in Redis operations.
  • Error Handling: The use of Either<Error, Unit> and Option<T> types from the TinyFp library helps in handling errors and optional values in a functional programming style.
  • Asynchronous Operations: The inclusion of asynchronous methods ensures that the application can perform Redis operations without blocking the main thread, improving performance and scalability.

Usage

Example
using TinyFp;
using Func.Redis.Extensions;
using Func.Redis;
using Microsoft.Extensions.DependencyInjection;
using Func.Redis.SerDes.Json;
using Microsoft.Extensions.Configuration;
using System.Text.Json;

// Configure services 
var config = new ConfigurationBuilder()
    .AddJsonFile("AppSettings.json", optional: false)
    .Build();

var services = new ServiceCollection();
// Use func-redis-extensions
services
  .AddRedis<SystemJsonRedisSerDes>(config, RedisCapabilities.Keys);

var serviceProvider = services.BuildServiceProvider();

// Resolve the Redis service 
var redisService = serviceProvider.GetRequiredService<IRedisKeyService>();

// Save and retrieve data
var result = await redisService
  .SetAsync("key", new TestData(42))
  .BindAsync(_ => redisService.GetAsync<TestData>("key"));

result
    .OnRight(o => o
        .OnSome(td => Console.WriteLine($"data found: {JsonSerializer.Serialize(td)}"))
        .OnNone(() => Console.WriteLine("data not found")))
    .OnLeft(e => Console.WriteLine($"Returned error {e.Message}"));

internal record TestData(int Id);
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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on func-redis:

Package Downloads
func-redis-extensions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-rc0005 39 11/15/2024
0.1.0-rc0004 44 11/12/2024
0.1.0-rc0003 41 11/8/2024
0.1.0-rc0002 36 11/7/2024