Lisun.RedisInterface
1.0.1
dotnet add package Lisun.RedisInterface --version 1.0.1
NuGet\Install-Package Lisun.RedisInterface -Version 1.0.1
<PackageReference Include="Lisun.RedisInterface" Version="1.0.1" />
<PackageVersion Include="Lisun.RedisInterface" Version="1.0.1" />
<PackageReference Include="Lisun.RedisInterface" />
paket add Lisun.RedisInterface --version 1.0.1
#r "nuget: Lisun.RedisInterface, 1.0.1"
#:package Lisun.RedisInterface@1.0.1
#addin nuget:?package=Lisun.RedisInterface&version=1.0.1
#tool nuget:?package=Lisun.RedisInterface&version=1.0.1
Lisun.RedisInterface
A lightweight and developer-friendly .NET library that simplifies working with Redis through a strongly typed, object-oriented API.
Instead of working directly with Redis commands, keys, serialization, and low-level data structures, Lisun.RedisInterface allows you to work with Redis using familiar C# types and objects.
Features
- Strongly typed Redis operations
- Object-oriented API
- Generic support for C# types
- Simplified Redis data access
- Reduced serialization boilerplate
- Easy integration with .NET applications
- Built on top of Microsoft's Redis caching infrastructure
- Designed for clean and maintainable application code
Requirements
- .NET 10.0 or later
- Redis server
- Microsoft.Extensions.Caching.StackExchangeRedis
Installation
Install the package using the .NET CLI:
dotnet add package Lisun.RedisInterface
Or using the NuGet Package Manager:
Install-Package Lisun.RedisInterface
Usage
- Set configurations in program.cs :
using Lisun.RedisInterface.Abstraction;
builder.Services.AddRedisInterface(option =>
{
option.InstanceName = "TestRedis";
option.Connection = builder.Configuration.GetConnectionString("Redis")!;
option.RedisServiceLifeTime = ServiceLifetime.Scoped;
});
- Make your C# object 'Cacheable' : this setting can be applied to types in two ways
- "ICacheable" :
using Lisun.RedisInterface.Abstraction;
public class Person : ICacheable
{
public int Id { get; set; }
public string Name { get; set; }
public string PostalCode { get; set; }
}
then in program.cs :
RedisInterface.RegisterConfig<Refer>(CacheSetting.Generate());
- "IConfigedCacheable" :
public class User : IConfigedCacheable
{
public static CacheSetting CacheSetting
=> new CacheSetting("User").ExpireAfter(TimeSpan.FromMinutes(2));
public int Id { get; set; }
public string Name { get; set; }
public string PostalCode { get; set; }
}
- Inject 'IRedisService' to manage cached data :
public class BaseService(
IRedisService<Person> personCacheService,
IRedisService<User> userCacheService)
{
public async Task Do(int personId)
{
var user = new User();
await userCacheService.SetAsync(user.Id.ToString(),user);
await personCacheService.GetAsync(personId.ToString());
}
}
This approach keeps Redis-related code simple, readable, and strongly typed.
License
This project is licensed under the MIT License.
Contributing
Contributions, issues, and feature requests are welcome.
Feel free to open an issue or submit a pull request on the project's GitHub repository.
⭐ Support the Project
If you find Lisun.RedisInterface useful, consider giving the project a ⭐ on GitHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.11)
- Microsoft.Extensions.Configuration (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of Lisun.RedisInterface, providing a strongly typed and object-oriented abstraction for working with Redis in .NET.