func-redis
0.1.0-rc0006
dotnet add package func-redis --version 0.1.0-rc0006
NuGet\Install-Package func-redis -Version 0.1.0-rc0006
<PackageReference Include="func-redis" Version="0.1.0-rc0006" />
paket add func-redis --version 0.1.0-rc0006
#r "nuget: func-redis, 0.1.0-rc0006"
// Install func-redis as a Cake Addin #addin nuget:?package=func-redis&version=0.1.0-rc0006&prerelease // Install func-redis as a Cake Tool #tool nuget:?package=func-redis&version=0.1.0-rc0006&prerelease
Functional Redis
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>
andOption<T>
types from theTinyFp
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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- SpanJson (>= 4.2.1)
- StackExchange.Redis (>= 2.8.16)
- System.Interactive.Async (>= 6.0.1)
- tiny-fp (>= 2.1.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- SpanJson (>= 4.2.1)
- StackExchange.Redis (>= 2.8.16)
- System.Interactive.Async (>= 6.0.1)
- tiny-fp (>= 2.1.0)
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-rc0006 | 31 | 11/27/2024 |
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 |